Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Operator '==' has no left operand

Given:

#if defined(TESTING) 
   #if (TESTING == UNIT_TEST)
            State<StateTypeEnum, EventTypeEnum>::_isIgnoredEvent = false;
            State<StateTypeEnum, EventTypeEnum>::_isInvalidEvent = false;
   #endif
#endif

where TESTING is defined, as is UNIT_TEST, and TESTING == UNIT_TEST, why is GCC saying

../testing/fsm/../../fsm/h/state.h:207:17: error: operator '==' has no left operand
    #if (TESTING == UNIT_TEST)
                 ^
like image 235
Mawg says reinstate Monica Avatar asked Jul 13 '14 07:07

Mawg says reinstate Monica


1 Answers

It appears that you've merely defined TESTING without defining it with a value, either inline, or as part of the compiler command line.

#define TESTING

It is defined, and #if defined tests true, but comparison won't work because its macro replacement value is nothing (or the wrong type).

If you give it a value, however, then your code works.

#define TESTING 1
#define UNIT_TEST 1

#if defined(TESTING) 
#if (TESTING == UNIT_TEST)
cout << "Unit test";
#endif
#endif
like image 97
codenheim Avatar answered Nov 15 '22 16:11

codenheim