Skip to content

CheckClass: renamed Bool enum values#8187

Merged
firewave merged 2 commits intodanmar:mainfrom
reshmavk:rename_macros
Feb 6, 2026
Merged

CheckClass: renamed Bool enum values#8187
firewave merged 2 commits intodanmar:mainfrom
reshmavk:rename_macros

Conversation

@reshmavk
Copy link
Contributor

@reshmavk reshmavk commented Feb 6, 2026

In AIX, TRUE and FALSE are already defined in AIX system header files. As a result, compiling cppcheck in AIX fails with the following errors:

/home/buildusr/cppcheck/lib/checkclass.h:231:38: error: expected identifier before numeric constant
  231 |     enum class Bool : std::uint8_t { TRUE, FALSE, BAILOUT };
      |                                      ^~~~
/home/buildusr/cppcheck/lib/checkclass.h:231:38: error: expected '}' before numeric constant
In file included from /home/buildusr/cppcheck/lib/astutils.cpp:37:
/home/buildusr/cppcheck/lib/checkclass.h:231:36: note: to match this '{'
  231 |     enum class Bool : std::uint8_t { TRUE, FALSE, BAILOUT };
      |                                    ^
In file included from /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include-fixed/wchar.h:50,
                 from /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include/c++/cwchar:44,
                 from /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include/c++/bits/postypes.h:40,
                 from /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include/c++/bits/char_traits.h:40,
                 from /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include/c++/string:40,
                 from /home/buildusr/cppcheck/lib/matchcompiler.h:23,
                 from /home/buildusr/cppcheck/build/lib/build/mc_astutils.cpp:1:
/home/buildusr/cppcheck/lib/checkclass.h:231:38: error: expected unqualified-id before numeric constant
  231 |     enum class Bool : std::uint8_t { TRUE, FALSE, BAILOUT };
      |                                      ^~~~
In file included from /home/buildusr/cppcheck/lib/astutils.cpp:37:
/home/buildusr/cppcheck/lib/checkclass.h:232:12: error: 'Bool' does not name a type; did you mean 'bool'?
  232 |     static Bool isInverted(const Token *tok, const Token *rhs);
      |            ^~~~
      |            bool
/home/buildusr/cppcheck/lib/checkclass.h:236:60: error: non-member function 'bool isMemberVar(const Scope*, const Token*)' cannot have cv-qualifier
  236 |     bool isMemberVar(const Scope *scope, const Token *tok) const;
      |                                                            ^~~~~
/home/buildusr/cppcheck/lib/checkclass.h:240:97: error: non-member function 'bool checkConstFunc(const Scope*, const Function*, MemberAccess&)' cannot have cv-qualifier
  240 |     bool checkConstFunc(const Scope *scope, const Function *func, MemberAccess& memberAccessed) const;
      |                                                                                                 ^~~~~
/home/buildusr/cppcheck/lib/checkclass.h:313:137: error: non-member function 'void initializeVarList(const Function&, std::__cxx11::list<const Function*>&, const Scope*, std::vector<Usage>&)' cannot have cv-qualifier
  313 |     void initializeVarList(const Function &func, std::list<const Function *> &callstack, const Scope *scope, std::vector<Usage> &usage) const;
      |                                                                                                                                         ^~~~~
/home/buildusr/cppcheck/lib/checkclass.h:344:1: error: expected declaration before '}' token
  344 | };
      | ^

In this PR, TRUE and FALSE is being renamed to True and False to resolve this issue. Please let me know your suggestions or concerns on these changes.

@firewave
Copy link
Collaborator

firewave commented Feb 6, 2026

Also rename BAILOUT and this will be be fine.

A usual workaround for this would also be to #undef those.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 6, 2026

@firewave firewave changed the title Rename TRUE AND FALSE CheckClass: renamed Bool enum values Feb 6, 2026
@firewave firewave merged commit dad374c into danmar:main Feb 6, 2026
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants