This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

identifier "uint32_t","uint8_t" is undefined

hello professors,

I have already add "stdint.h" header in .c file, but when I compile the project, the corresponding .h file shows that identifier "uint32_t","uint8_t" is undefined.


do I still need to add the stdint.h into the .h file?

thanks so much for your advice

  • Everywhere where these types of declaration is used you need to include “stdint.h” file, but it’s enough to include it once in the header file and not in the source .c file when that header file is included in the source file.

  • Leo is right. The compiler starts each .c file compilation from scratch. And top-down. So you need to include stdint.h each time before you use it, whether in another header you include or in the .c file.

    Any header file that uses these types should include stdint.h anyway. Also, header files are usually written with an #ifndef/#define/#endif frame, so they are included only once in a compiler run, no matter how often they are included.
    #ifndef __MYHEADER_H__
    #define __MYHEADER_H__
    [Include file content]
    #endif // __MYHEADER_H__

    Once included for the first time, __MYHEADER_H__ is defined and the content will be skipped on the second inclusion.
    However, some header files are designed for multiple inclusion (e.g. the header for the USCI registers). These files then use external defines that are changed before each inclusion, resulting in a different header file interpretation (like generating register defines for USCI0, USCI1, USCI2 etc.). But this is very advanced stuff, playing with the advanced preprocessor capabilities.

**Attention** This is a public forum