Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 729793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:50:19+00:00 2026-05-14T06:50:19+00:00

I’m getting a really strange error when making a method call: /* input.cpp */

  • 0

I’m getting a really strange error when making a method call:

   /* input.cpp */

#include <ncurses/ncurses.h>
#include "input.h"
#include "command.h"

Input::Input ()
{
    raw ();
    noecho ();
}

Command Input::next ()
{
    char input = getch ();
    Command nextCommand;

    switch (input)
    {
    case 'h':
        nextCommand.setAction (ACTION_MOVELEFT);
        break;
    case 'j':
        nextCommand.setAction (ACTION_MOVEDOWN);
        break;
    case 'k':
        nextCommand.setAction (ACTION_MOVEUP);
        break;
    case 'l':
        nextCommand.setAction (ACTION_MOVERIGHT);
        break;
    case 'y':
        nextCommand.setAction (ACTION_MOVEUPLEFT);
        break;
    case 'u':
        nextCommand.setAction (ACTION_MOVEUPRIGHT);
        break;
    case 'n':
        nextCommand.setAction (ACTION_MOVEDOWNLEFT);
        break;
    case 'm':
        nextCommand.setAction (ACTION_MOVEDOWNRIGHT);
        break;
    case '.':
        nextCommand.setAction (ACTION_WAIT);
        break;
    }


    return nextCommand;
}

and the error:

Administrator@RHYS ~/code/rogue2
$ make
g++ -c -Wall -pedantic -g3 -O0 input.cpp
input.cpp: In member function `Command Input::next()':
input.cpp:21: error: expected primary-expression before '=' token
input.cpp:24: error: expected primary-expression before '=' token
input.cpp:27: error: expected primary-expression before '=' token
input.cpp:30: error: expected primary-expression before '=' token
input.cpp:33: error: expected primary-expression before '=' token
input.cpp:36: error: expected primary-expression before '=' token
input.cpp:39: error: expected primary-expression before '=' token
input.cpp:42: error: expected primary-expression before '=' token
input.cpp:45: error: expected primary-expression before '=' token
make: *** [input.o] Error 1

Sorry about the lack of linenumbers, the errors occur on the lines “nextCommand.setAction(…)”, which is totally bizarre considering that they don’t contain a ‘=’.

Any ideas?
Thanks,

Rhys

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:50:19+00:00Added an answer on May 14, 2026 at 6:50 am

    Here’s the only thing I can think of (without seeing more code) that would cause this:

    Your identifiers in all-caps are macros, defined something like this:

    #define ACTION_MOVELEFT = 1
    #define ACTION_MOVEDOWN = 2
    

    and so on. When the macros are then expanded, you end up with code like:

    case 'h':
        nextCommand.setAction (= 1);
        break;
    

    The = is not used to define a macro; for object-like macros, everything following the macro name until the newline ending the macro definition is part of the replacement list. So, the macros should be defined as follows:

    #define ACTION_MOVELEFT 1
    #define ACTION_MOVEDOWN 2
    

    and so on.

    However, you should consider using an enumeration to enforce type safety and to avoid using the preprocessor when it doesn’t need to be used:

    enum ActionType
    {
        ActionMoveLeft,
        ActionMoveDown
    };
    

    Or, at the very least, use const ints rather than #defines.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 413k
  • Answers 413k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can take in one table at a time using… May 15, 2026 at 8:20 am
  • Editorial Team
    Editorial Team added an answer Here's some hard numbers, demonstrating that exact timings vary from… May 15, 2026 at 8:20 am
  • Editorial Team
    Editorial Team added an answer These are blocks which add anonymous functions and function objects… May 15, 2026 at 8:20 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.