SIZEOF_LONG 4 instead of 8 in 64-bits

Jonathan Saxton jsaxton@appsecinc.com
Tue May 18 22:23:00 GMT 2010



-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On Behalf Of Tim Prince
Sent: Tuesday 18 May 2010 13:55
To: gcc-help@gcc.gnu.org
Subject: Re: SIZEOF_LONG 4 instead of 8 in 64-bits

On 5/18/2010 10:50 AM, Ian Lance Taylor wrote:
> Kraiser<pietiatibia1@gmail.com>  writes:
>
>    
>> I need to use #define __SIZEOF_LONG__ 4 instead of #define __SIZEOF_LONG__ 8
>> in amd64 so my program will not double the memory usage how Can i do so?
>> using debian and gcc 4.4.4
>>      
> No, there is no support for that.  Sorry.
>
> Perhaps you could compile with -Dlong=int.  Wouldn't work if you ever
> use the long long type, though.
>
> Ian
>    
or correct your program to use int32_t if that is your intention

-- 
Tim Prince



I have not been following this discussion since the beginning and so I don't know if it is applicable here but I use a little template metaprogram to establish an alias for an integer with a size equal to machine address width when I need such a thing.  It comes out a bit like size_t or ssize_t without the need to cast.  It would be just as easy to do the same for a 32-bit integer.

The advantage of this approach is that you are never dependent on things like int_32 or variants thereof which may or may not be defined for any particular platform.  So long as one of the C/C++ integer types has the desired size, you get what you want.



More information about the Gcc-help mailing list