64 bit longs in gcc?

From: Tris Orendorff (triso_at_remove-me.cogeco.ca)
Date: 03/22/04


Date: Mon, 22 Mar 2004 15:55:02 GMT

Hi,

How can I get 64 bit longs in gcc for Linux x86? I don't want 64 bit pointers, either. I am attempting to
modify Unix Tree under Linux and the code is written with 64 bit longs for all the other configurations (VMS,
AIX, BSD, etc.) Byte counts wrap at 2GB when long is only 32 bits.

Reading through the gcc man page, all the other systems with 32 bit ints have 64 bit longs.

I am able to convert stat.st_size to 64 bits by using "-D_FILE_OFFSET_BITS=64" on the command line.
This gives me a new type, off_t, that is 64 bits but then I have to convert all other files to use off_t rather
than long but only where the variable is a file size and not an unrelated long variable. This is too error
prone and also messes up all the code for the other machines.

Does anyone have any suggestions?

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d++ s+:- a+ C+ UL++++ P+ L+ E- W+ N++ o- K++ w+ O+ M !V PS+ PE Y+ PGP t+ !5 X- R- tv--- b++
DI++ D+ G++ e++ h---- r+++ y+++
------END GEEK CODE BLOCK------



Relevant Pages

  • Re: Portable assignment
    ... computes exactly the same value (assuming 32-bit longs) as: ... even in the case of wrap around! ... -Larry Jones ... You should see me when I lose in real life! ...
    (comp.lang.c)
  • unsigned long to double
    ... I've got a list of longs which I need to fix. ... Basically the numbers come from an unsigned long, which will wrap back ... to zero. ...
    (comp.lang.c)