Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'uint32_t' identifier not found error

Tags:

c++

c

visual-c++

I'm porting code from Linux C to Visual C++ for windows.

Visual C++ doesn't know #include <stdint.h> so I commented it out.

Later, I found a lot of those 'uint32_t': identifier not found errors. How can it be solved?

like image 237
kevin Avatar asked Mar 02 '11 02:03

kevin


People also ask

Where is uint32_t defined C++?

This type is defined in the C header <stdint. h> which is part of the C++11 standard but not standard in C++03. According to the Wikipedia page on the header, it hasn't shipped with Visual Studio until VS2010. Hope this helps!

Why do we use uint32_t in network programming why not use unsigned int instead?

And the reason why people use uint32_t rather than the other types is because they usually don't have such hardware to do testing on. (The same is true of int32_t to a lesser extent, and even int and short ). An example of the corner case: Let unsigned short == uint32_t and int == int48_t .


1 Answers

This type is defined in the C header <stdint.h> which is part of the C++11 standard but not standard in C++03. According to the Wikipedia page on the header, it hasn't shipped with Visual Studio until VS2010.

In the meantime, you could probably fake up your own version of the header by adding typedefs that map Microsoft's custom integer types to the types expected by C. For example:

typedef __int32 int32_t; typedef unsigned __int32 uint32_t; /* ... etc. ... */ 

Hope this helps!

like image 94
templatetypedef Avatar answered Oct 08 '22 23:10

templatetypedef