Menu

false positive error with "not" macro and a constant value

2020-11-24
2020-11-26
  • Cristian Del Fabbro

    Cppcheck 2.2 reports an error in this (working) code:

    #include <iostream>
    int main() {
        bool a = 0;
        bool b = not a;
        bool c = not 0; // <--- here
    
        // output is "0 1 1"
        std::cout << a << " " << b << " " << c << std::endl;
        return 0;
    }
    

    Error:

    test.cpp:5:11: error: There is an unknown macro here somewhere. Configuration is required. If not is a macro then please configure it. [unknownMacro]
     bool c = not 0;
              ^
    

    Cppcheck reports an error with every constant, not only with "0".

    Best,
    Cristian

     
  • Daniel Marjamäki

     

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.