Menu

Cppcheck doesn't treat bool as a C++ keyword when using std=C++11

2019-03-26
2019-04-12
  • Sebastian Cabot

    Sebastian Cabot - 2019-03-26

    Hello,

    I am trying to check my code that was written in C++. I pass the std=c++11 flag to cppcheck (I am using the GUI) but I keep getting: Skipping configuration 'bool' since the value of 'bool' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.

    Any ideas on how to over come this? This information warning makes me think that mavbe other C++11 features are not properly checked as well.

    Thank you
    Sebastian

     
    • Sebastian Cabot

      Sebastian Cabot - 2019-04-10

      Hello.
      I could not reproduce this on a small test case.
      Apparently there are some system includes that define bool.
      I am sorry for not thinking about checking it this way before posting.

      Thank you very much

      On Tue, Mar 26, 2019 at 6:23 PM Sebastian Cabot scabot@users.sourceforge.net wrote:

      Hello,

      I am trying to check my code that was written in C++. I pass the std=c++11
      flag to cppcheck (I am using the GUI) but I keep getting: Skipping
      configuration 'bool' since the value of 'bool' is unknown. Use -D if you
      want to check it. You can use -U to skip it explicitly.

      Any ideas on how to over come this? This information warning makes me
      think that mavbe other C++11 features are not properly checked as well.

      Thank you
      Sebastian


      Cppcheck doesn't treat bool as a C++ keyword when using std=C++11
      https://sourceforge.net/p/cppcheck/discussion/general/thread/7bece648a0/?limit=25#653c


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/cppcheck/discussion/general/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • versat

    versat - 2019-04-01

    What version of Cppcheck are you using?
    Does it work when you change the std to c++14?
    Can you provide some minimal example code piece where that issue happens?

     
    • Sebastian Cabot

      Sebastian Cabot - 2019-04-10

      Hello.
      I could not reproduce this on a small test case.
      Apparently there are some system includes that define bool.
      I am sorry for not thinking about checking it this way before posting.

      Thank you very much

       
      • versat

        versat - 2019-04-12

        Thanks for the response.
        Maybe it is useful to exclude the system includes or not adding them to the includes. It is recommended for Cppcheck analysis to not use standard/system includes but use the library configurations that come with Cppcheck.

        I have tried to reproduce the message that you got regarding unknown configuration of "bool" and i got it for example when using code like this:

        #ifdef bool
        #endif
        
        void f(bool a)
        {}
        

        Cppcheck output:

        $ ./cppcheck --enable=all bool.cpp
        Checking bool.cpp ...
        [bool.cpp:4]: (information) Skipping configuration 'bool' since the value of 'bool' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.
        Checking bool.cpp: bool...
        [bool.cpp:4]: (style) The function 'f' is never used.
        

        If you know that bool should always be bool you can call Cppcheck with -Dbool=bool:

        $ ./cppcheck --enable=all -Dbool=bool bool.cpp
        Checking bool.cpp ...
        Checking bool.cpp: bool=bool...
        [bool.cpp:4]: (style) The function 'f' is never used.
        

        I you have further questions or find out more about this case it would be great if you let us know :)

         

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.