Search code examples
ctypestypedefstdintuint32-t

C type declaration intN_t


How does the header stdint.h define u32 to be 32 bits on every machine? Could somebody elaborate on the process that stdint.h does to make this happen? Where can I find my machine's (Windows 7) stdint.h file?


Solution

  • stdint.h is in the C99 (and VC++ of versions below 2008 only implements C89), so to have this file on a Win7 machine you need either VisualStudio 2010 (or later) installed. Then this file is in the "VC\include\stdint.h" folder of your MSVS installation.

    MinGW (gcc toolchain for Win32) and Cygwin (POSIX layer for windows machines) also include the stdint.h file in their "include" directory.

    To your question: the "magic" behind uintN_t types is typically implemented using conditional compilation. There may be some symbols predefined (by the compiler), like _WIN32 on Windows and _WIN64 for x64 targets.

    For the pre-2008 versions of VisualStudio there's a separate stdint.h implementation: http://msinttypes.googlecode.com/svn/trunk/stdint.h