14

Possible Duplicate:
Datatypes used in C

Hi I'm doing porting from Linux to Visual C ++. And I found quite a few errors. What is u_int32_t ? I can't find it in Visual C ++? Is it only available in Linux? Which type should I use in Visual C++? Thanks in advance !!!

Kevin

Community
  • 1
  • 1
kevin
  • 13,559
  • 30
  • 79
  • 104

5 Answers5

15

The C99 header stdint.h defines types that do not depend on architecture or compiler. The meaning of unsigned int can differ (e.g. 16bit wide on a 16bit system), but those types from stdint.h have a specific size.

Either the additional underscore accidentally slipped in there, or someone re-typed them for some library or whatever. If the latter one is the case, include some header of your own, in that header include stdint.h and make sure to typedef uint32_t u_int32_t after the include.

0xC0000022L
  • 20,597
  • 9
  • 86
  • 152
7

These not-quite-standard names appear to have been introduced by BSD: http://lists.freedesktop.org/archives/release-wranglers/2004-August/000923.html

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
2

I am not fully sure about the exact type, but based on the name, it looks like an unsigned 32 bit integer. The corresponding type in Visual C++ would be unsigned int.

There are other Aliases for that, but this name would suffice.

Shamim Hafiz - MSFT
  • 21,454
  • 43
  • 116
  • 176
2

This is an int datatype that is unsigned guaranteed to be 32 bits. To use it you need to include the stdint.h.

I am not sure whether this is available directly in the latest version of VC++. The wikipedia page has links to various implementations that work with Microsoft compilers (e.g. msinttypes).

If you are sure that the default unsigned int type is always going to be 32 bits, you may be able to just substitute unsigned int in its place. But using an explicit 32 bit datatype is preferable.

MAK
  • 26,140
  • 11
  • 55
  • 86
  • VC++ 2010 (currently the latest version) does indeed provide `stdint.h`. But `stdint.h` provides the standard name `uint32_t`, not `u_int32_t` as mentioned in this question. – Ben Voigt Mar 02 '11 at 05:56
1

Not sure about u_int32_t, but uint32_t is a standard type according to the 1999 version of the C standard, coming from <stdint.h>.

Visual C++ has made a choice not to adopt C99, so it is not supported there. If you include <windows.h> you can just use DWORD, which will be the same size and also unsigned.

asveikau
  • 39,039
  • 2
  • 53
  • 68