Menu

cppcheck compilation fails in AIX due to system standards.h header file and enum TRUE/FALSE conflicts

2025-09-18
2025-11-27
  • Reshma V Kumar

    Reshma V Kumar - 2025-09-18

    Hi All,

    I am building cppcheck in AIX using gcc compiler. The compilation fails with the following errors:

    1. multiple undeclared errors as shown below:
    /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include/c++/cstdint:47:11: error: 'int8_t' has not been declared in '::'
       47 |   using ::int8_t;
          |           ^~~~~~
    /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include/c++/cstdint:48:11: error: 'int16_t' has not been declared in '::'
       48 |   using ::int16_t;
          |           ^~~~~~~
    /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include/c++/cstdint:49:11: error: 'int32_t' has not been declared in '::'
       49 |   using ::int32_t;
          |           ^~~~~~~
    /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include/c++/cstdint:50:11: error: 'int64_t' has not been declared in '::'
       50 |   using ::int64_t;
          |           ^~~~~~~
    /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include/c++/cstdint:52:11: error: 'int_fast8_t' has not been declared in '::'
       52 |   using ::int_fast8_t;
          |           ^~~~~~~~~~~
    /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include/c++/cstdint:53:11: error: 'int_fast16_t' has not been declared in '::'
    

    A complete error log is attached.
    In AIX, there is a system header file named standards.h and cppcheck also has a header file with the same name.
    The system header defines certain macros based on which types like int8_t,int16_t,etc are defined in stdint.h header file.
    During the compilation, standards.h provided by cppcheck takes precedence and system header file is not included. This results in the above errors.
    To resolve this, we have renamed the cppcheck provided "standards.h" to "cppcheckstd.h" and replaced #include "standards.h" to #include "cppcheckstd.h" in the source code wherever necessary.

    2.

    /home/buildusr/reshma/patch_contribution/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/reshma/patch_contribution/cppcheck/lib/astutils.cpp:37:
    /home/buildusr/reshma/patch_contribution/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/reshma/patch_contribution/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/reshma/patch_contribution/cppcheck/lib/checkclass.h:240:97: error: non-member function 'bool checkConstFunc(const Scope*, const Function*, MemberAccess&)' cannot h
    ave cv-qualifier
      240 |     bool checkConstFunc(const Scope *scope, const Function *func, MemberAccess& memberAccessed) const;
          |                                                                                                 ^~~~~
    /home/buildusr/reshma/patch_contribution/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/reshma/patch_contribution/cppcheck/lib/checkclass.h:344:1: error: expected declaration before '}' token
    

    TRUE and FALSE are macros that are defined in AIX system header file. So, we have renamed TRUE and FALSE to True and False respectively. This fixes the above issue.

    The patches for both the issues are attached. Please let me know your suggestions on these changes.

     

    Last edit: Reshma V Kumar 2025-09-18
  • Reshma V Kumar

    Reshma V Kumar - 2025-11-27

    Could any of the maintainers look into this and let me know your suggestions?

     
  • CHR

    CHR - 2025-11-27

    Please open a PR containing your patches.

     

Log in to post a comment.