Search code examples
eclipse-cdtcodan

How does Eclipse CDT understand __SIZE_TYPE__?


When I open the declaration of size_t in Eclipse I get to stddef.h from GCC with the line: typedef __SIZE_TYPE__ size_t;

I understand that __SIZE_TYPE__ is not defined in any header file, but is known by the compiler.

But, how does Eclipse CDT understand that __SIZE_TYPE__ and size_t are integer types, so it can do code analysis etc? Is it built into CDT?


Solution

  • I finally figured it out.

    __SIZE_TYPE__ can be found at Project Properties -> C/C++ General -> Preprocessor Include Paths, Macros etc. -> Entries -> CDT GCC Built in Compiler Settings, where it says __SIZE_TYPE__ = unsigned int.

    Looking at the Providers tab, CDT extracts the list from GCC by running ${COMMAND} -E -P -v -dD ${INPUTS}, where ${COMMAND} is gcc and ${INPUTS} is an empty C or C++ file.

    -E preprocess only -P no linemarkers -v verbose -dD Dump all macro definitions.

    GCC outputs various internal defines including #define __SIZE_TYPE__ unsigned int