Domanda

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?

È stato utile?

Soluzione

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

Altri suggerimenti

The provider of the C standard library for the compiler toolchain will ensure that it is correct for that particular deployment. Presumably they are allowed to use whatever means necessary to ensure this is the case. It could be as simple as knowing whether to typedef it to int or long.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top