![](https://secure.gravatar.com/avatar/7cfdb0d0d2a0dd63dfe86a0987064ff6.jpg?s=120&d=mm&r=g)
2011/2/1 René Dudfield <renesd@gmail.com>:
Hi,
A naive guess would be the different sizes between 64bit windows, and 64 bit linux? (long int is 32bit on windows and 64bit on linux)
From http://en.wikipedia.org/wiki/64-bit
64-bit data models Data model short (integer) int long (integer) long long pointers/size_t Sample operating systems LLP64/ IL32P64 16 32 32 64 64 Microsoft Windows (X64/IA-64) LP64/ I32LP64 16 32 64 64 64 Most Unix and Unix-like systems, e.g. Solaris, Linux, and Mac OS X ILP64 16 64 64 64 64 HAL Computer Systems port of Solaris to SPARC64 SILP64 64 64 64 64 64 Unicos
From what Amaury said, you need to identify places where long is used and it is assumed that it has 64bits. A first guess, in general, is that _every_ use of long assumes it to be 64bit on 64bits systems.
What about using intptr_t (or uintptr_t) from stdint.h? IOW, you'd simply replace long by this type everywhere, including in functions which generate C code through some library. I don't know the details, could somebody help here? IIRC this header was introduced in C99, and for sure this type is optional - i.e., it must be declared if it is available at all. Of course, there might be systems where this type is not available, so you need to provide a fallback (in a configure-like fashion). If this header is available on (modern) Windows environments (the only system where long is 32 bits), using "long" as fallback is safe. Cheers, -- Paolo Giarrusso - Ph.D. Student http://www.informatik.uni-marburg.de/~pgiarrusso/