Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Rev. 7830 build issues
killerbot:
--- Quote from: MortenMacFly on February 22, 2012, 08:02:53 am ---Because on 32 bit its unsigned long int, on 64 bit its unsigned long long (size_t).
--- End quote ---
Yes, so, if I look at the ifdef posted above (note WIN64 --> what happens on linux 64 bit ??) :
if WIN64 bit --> size_t ==> 64 bits BUT unsigned long is also 64 bit on 64 bits machines
else (considering this means 32 bit !!!! ??)
unsigned long ==> 32 bits, but size_t is also 32 bits here
Meaning that either unsigned long can be used in both cases, or for that matter size_t can be used for both.
When using unsigned long for printf '%lu' can be used,
and for size_t "%zu"
MortenMacFly:
--- Quote from: killerbot on February 22, 2012, 01:07:09 pm ---and for size_t "%zu"
--- End quote ---
Uaaah - careful here, remember that this caused a silent crash? I would prefer a solution that uses a well established standard... hence I don't know any. :-(
Biplab:
--- Quote from: killerbot on February 22, 2012, 01:07:09 pm ---
--- Quote from: MortenMacFly on February 22, 2012, 08:02:53 am ---Because on 32 bit its unsigned long int, on 64 bit its unsigned long long (size_t).
--- End quote ---
Yes, so, if I look at the ifdef posted above (note WIN64 --> what happens on linux 64 bit ??) :
if WIN64 bit --> size_t ==> 64 bits BUT unsigned long is also 64 bit on 64 bits machines
else (considering this means 32 bit !!!! ??)
unsigned long ==> 32 bits, but size_t is also 32 bits here
Meaning that either unsigned long can be used in both cases, or for that matter size_t can be used for both.
When using unsigned long for printf '%lu' can be used,
and for size_t "%zu"
--- End quote ---
Win 32 -
size_t => unsigned long int
Win 64 -
size_t => unsigned long long int
Linux 32 & 64 bit
size_t => unsigned long int
So if you use size_t it'll work on all platform. However printf format identifier will be different only under Win 64. You have to use %I64u printf format string to print unsigned 64 bit integer.
Jenna:
As far as I know size_t is usually the same as __SIZE_TYPE__
--- Quote from: Biplab on February 22, 2012, 02:20:45 pm ---Win 32 -
size_t => unsigned long int
--- End quote ---
__SIZE_TYPE__ => unsigned int
--- Quote from: Biplab on February 22, 2012, 02:20:45 pm ---Win 64 -
size_t => unsigned long long int
--- End quote ---
not tested
--- Quote from: Biplab on February 22, 2012, 02:20:45 pm ---Linux 32 & 64 bit
size_t => unsigned long int
--- End quote ---
Linux 32:
__SIZE_TYPE__ => unsigned int
Linux 64:
__SIZE_TYPE__ => long unsigned int
Biplab:
--- Quote from: jens on February 22, 2012, 03:28:39 pm ---As far as I know size_t is usually the same as __SIZE_TYPE__
--- Quote from: Biplab on February 22, 2012, 02:20:45 pm ---Win 32 -
size_t => unsigned long int
--- End quote ---
__SIZE_TYPE__ => unsigned int
--- Quote from: Biplab on February 22, 2012, 02:20:45 pm ---Win 64 -
size_t => unsigned long long int
--- End quote ---
not tested
--- Quote from: Biplab on February 22, 2012, 02:20:45 pm ---Linux 32 & 64 bit
size_t => unsigned long int
--- End quote ---
Linux 32:
__SIZE_TYPE__ => unsigned int
Linux 64:
__SIZE_TYPE__ => long unsigned int
--- End quote ---
Win32:
--- Code: ---sizeof(int)=sizeof(long)=sizeof(unsigned long)=4
--- End code ---
Win64:
--- Code: ---sizeof(int)=sizeof(long)=sizeof(unsigned long)=4
sizeof(long long)=sizeof(unsigned long long)=8
--- End code ---
Linux-32-bit:
--- Code: ---sizeof(int)=sizeof(long)=sizeof(unsigned long)=4
--- End code ---
Linux-64-bit:
--- Code: ---sizeof(int)=4
sizeof(long)=sizeof(unsigned long)=8
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version