This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Compier checks section under #ifdef UNDEFINED -> error

It seems a bug crept in CC ARM, may be not only ARM. Consider next code:

#ifdef IDENTIFIER
    IDENTIFIER();
#endif

and build output:

..\..\src\module\module.cpp(344): error:  #20: identifier "IDENTIFIER" is undefined


GCC does not have such problem. Check <a href=coliru.stacked-crooked.com/.../7e6350bd2bfbc14a >here</a>

Parents
  • If you had written:

    #define IDENTIFIER charlie
    
    #ifdef IDENTIFIER
        IDENTIFIER()
    #endif
    

    Then IDENTIFIER would have been defined and you would have ended up with:

        charlie()
    


    And the compiler - and later linker - would have to figure out if any function named "charlie" exists.

    But I don't think your code contains any:

    #define IDENTIFIER charlie
    

    So what would happen if IDENTIFIER would expand to something else? Remember that you might even go all the way and have:

    #define IDENTIFIER
    


    where you haven't given IDENTIFIER any specific value to expand to. This is also covered by the standard.

Reply
  • If you had written:

    #define IDENTIFIER charlie
    
    #ifdef IDENTIFIER
        IDENTIFIER()
    #endif
    

    Then IDENTIFIER would have been defined and you would have ended up with:

        charlie()
    


    And the compiler - and later linker - would have to figure out if any function named "charlie" exists.

    But I don't think your code contains any:

    #define IDENTIFIER charlie
    

    So what would happen if IDENTIFIER would expand to something else? Remember that you might even go all the way and have:

    #define IDENTIFIER
    


    where you haven't given IDENTIFIER any specific value to expand to. This is also covered by the standard.

Children