I have the source code of an application written in C++ and I just want to comment something using:
#ifdef 0
...
#endif
And I get this error
error: macro names must be identifiers
Why is this happening?
This question is related to
c++
macros
c-preprocessor
This error can also occur if you are not following the marco rules
Like
#define 1K 1024 // Macro rules must be identifiers error occurs
Reason: Macro Should begin with a letter, not a number
Change to
#define ONE_KILOBYTE 1024 // This resolves
#ifdef 0
...
#endif
#ifdef expect a macro rather than expression when using constant or expression
#if 0
...
#endif
or
#if !defined(PP_CHECK) || defined(PP_CHECK_OTHER)
..
#endif
if #ifdef is used the it reports this error
#ifdef !defined(PP_CHECK) || defined(PP_CHECK_OTHER)
..
#endif
Where #ifdef expect a macro rather than macro expresssion
Use the following to evaluate an expression (constant 0 evaluates to false).
#if 0
...
#endif
Use the following to evaluate an expression (constant 0 evaluates to false).
#if 0
...
#endif
Use the following to evaluate an expression (constant 0 evaluates to false).
#if 0
...
#endif
This error can also occur if you are not following the marco rules
Like
#define 1K 1024 // Macro rules must be identifiers error occurs
Reason: Macro Should begin with a letter, not a number
Change to
#define ONE_KILOBYTE 1024 // This resolves
Note that you can also hit this error if you accidentally type:
#define <stdio.h>
...instead of...
#include <stdio.>
#ifdef 0
...
#endif
#ifdef expect a macro rather than expression when using constant or expression
#if 0
...
#endif
or
#if !defined(PP_CHECK) || defined(PP_CHECK_OTHER)
..
#endif
if #ifdef is used the it reports this error
#ifdef !defined(PP_CHECK) || defined(PP_CHECK_OTHER)
..
#endif
Where #ifdef expect a macro rather than macro expresssion
Note that you can also hit this error if you accidentally type:
#define <stdio.h>
...instead of...
#include <stdio.>
Use the following to evaluate an expression (constant 0 evaluates to false).
#if 0
...
#endif
Source: Stackoverflow.com