Subscribe

Flag -m64: problem or bug?

  1. 2012-03-06 09:01:02 PST
    I have faced this problem compiling NetCDF library: even with the -m64 flag "long" is 32 bit. Here is the official "-m64" flag description: "The -m64 option sets int to 32 bits and long and pointer types to 64 bits, and generates code for the x86-64 architecture." Source: http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options What I see is presumably a bug: long is still 32 bit, only long long is 64 bit. Below is the illustration, copied form a console: H:\bug>dir /b sizeof-test.cpp H:\bug>type sizeof-test.cpp #include <stdio.h> int main() { printf("sizeof(long) = %d, sizeof(long long) = %d.\n", sizeof(long), sizeof(long long)); return 0; } H:\bug>x86_64-w64-mingw32-gcc.exe -m64 sizeof-test.cpp -o sizeof-test.exe H:\bug>sizeof-test.exe sizeof(long) = 4, sizeof(long long) = 8. H:\bug>dir /b sizeof-test.cpp sizeof-test.exe I am using the most recent distribution mingw-w64-bin_i686-mingw_20111220.zip. Another one I tried mingw-w64-bin_x86_64-mingw_20111101_sezero.zip has the same problem. Any comments? Thanks, nik-nik-nik
  2. 2012-03-06 09:47:28 PST
    GCC docs are wrong. Presumably no-one bothered or even saw this little oversight. On Windows, long is 32-bit, everywhere. Code assuming long is the same size as a pointer is non-Standard, and prone to bugs like the one preventing you to compile netCDF. netCDF must fix their code. See http://msdn.microsoft.com/en-us/library/cc953fe1.aspx .
Jump To:
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.