Search code examples
gcceclipse-cdt

eclipse cdt can't parse <stdint.h>


My eclipse does red-underline to uint32_t, uint16_t, etc... though I included <stdint.h> and set preprocessor path!

To know why it happens, I looked in <stdint.h>.

#ifndef _GCC_WRAP_STDINT_H
#if __STDC_HOSTED__
# if defined __cplusplus && __cplusplus >= 201103L
#  undef __STDC_LIMIT_MACROS
#  define __STDC_LIMIT_MACROS
#  undef __STDC_CONSTANT_MACROS
#  define __STDC_CONSTANT_MACROS
# endif
# include_next <stdint.h>        // here
#else
# include "stdint-gcc.h"
#endif
#define _GCC_WRAP_STDINT_H
#endif

Um, I think it seems that eclipse can't recognize #include_next. But I don't know solution.. Could you give me a advice?


Solution

  • First, to avoid #include_next, we should tell eclipse that __STDC_HOSTED__ is 0. In Project > Properties > C/C++ General > Path and Symbols, add __STDC_HOSTED__ as 0.

    Second, you can see some codes like the following in stdint-gcc.h.

    #ifdef __INT8_TYPE__
    typedef __INT8_TYPE__ int8_t;
    #endif
    

    __INT8_TYPE__ things are predefined macros of gcc. We must tell eclipse about them as well. So, add all macros from gcc -E -dM - < /dev/null except __STDC_HOSTED__ which we added before.