Operator '==' has no left operand

c++, c-preprocessor, gcc

Solution

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

Problem

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) ^ ```

Original source