tags:

views:

97

answers:

2

gcc c99 MS2005/2008

I have started program that will be compiled on linux/windows.

The program will be compiled on linux using gcc 4.4.1 c99. And on windows the compiler will be either MS 2005/2008. And this I cannot change.

I am using SCons to create the build files. However, the reason I choose c99 as I can use the stdint.h so my integers would be compatible between different architectures i.e. x86_32 and 64 bit. using int32_t so it will compile without any problem on both 32 and 64 bit machines.

However, I have just discovered that c99 isn't used for ms compilers. Only c89. However, c89 doesn't have the stdint.t.

I am wondering what is the best way to make the integer portable among different compilers running on either 32 or 64.

Many thanks for any advice,

+1  A: 

If you're not actually trying to directly map a binary format "from the wire", then you probably don't really need a fixed-width type at all.

By way of example, if you're using int32_t just because you need an integer than can store all values in the range -2147483647 to 2147483647, then a simple long is perfectly portable for that application - it is guaranteed to be at least that wide.

People seem to be inordinately keen on exact-width types.

caf