Unknown type name 'uint8_t', MinGW

I get an "unknown name like" uint8_t "and the other using C in MinGW. Any ideas how to solve this?

+42
c windows mingw
Jan 21 2018-12-21T00:
source share
3 answers

Try turning on stdint.h or inttypes.h .

+83
Jan 21 '12 at 13:21
source share

To use an alias like uint8_t , you must include the standard stdint.h header.

+10
Jan 21 2018-12-21T00:
source share

You need #include stdint.h BEFORE you #include any other library interfaces that need it.

Example:

My LCD library uses uint8_t types. I wrote my library with an interface ( Display.h ) and an implementation ( Display.c )

In display.c, I have the following options.

 #include <stdint.h> #include <string.h> #include <avr/io.h> #include <Display.h> #include <GlobalTime.h> 

And it works.

However, if I reorder them like this:

 #include <string.h> #include <avr/io.h> #include <Display.h> #include <GlobalTime.h> #include <stdint.h> 

I get an error message. This is because Display.h needs things from stdint.h , but cannot access it, because this information is compiled AFTER Display.h is displayed.

So, move stdint.h over any library that needs it, and you should no longer get the error.

+4
Apr 26 '14 at 2:54 on
source share



All Articles