Menu

Syntax Error 'ifdef ... namespace'

TKS
2024-10-15
2024-10-15
  • TKS

    TKS - 2024-10-15

    This is my first post, I would like to start with a big Thank You! for all the work you are investing to provide this great tool.

    We have just updated from cppcheck 2.13.0 to 2.15.0.

    I have this code in my cpp file:

    //#define XXX blah
    
    #ifdef XXX
    namespace XXX {
    #endif
    
    // do a lot of things
    
    #ifdef XXX
    } // namespace XXX
    #endif
    

    Using cppcheck 2.13.0, everything is OK, using 2.15.0 a syntax error occurs:

    $ cppcheck-2.15.0 src/demo.cpp
    Checking src/demo.cpp ...
    Checking src/demo.cpp: XXX...
    src/demo.cpp:4:11: error: syntax error [syntaxError]
    namespace XXX {
              ^
    

    uncommenting the first line, the syntax error disappears.

    Thanks again,
    Thorsten

     
  • CHR

    CHR - 2024-10-15

    WIthout this line //#define XXX blah cppcheck assumes XXX is defined as 1, so that define must be visible.

     

    Last edit: CHR 2024-10-15
  • TKS

    TKS - 2024-10-15

    Ouch! Of course you're right. I will check how I can change our code.

    Sorry, and thanks for your support!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.