digitalmars.D - Re: int always 32 bits on all platforms?
- Sean Kelly <sean invisibleduck.org> Oct 21 2009
- "AJ" <aj nospam.net> Oct 21 2009
AJ Wrote:How can/does D guarantee that "int" will always be 32 bits on all platforms? Does this mean that D won't work on some platforms? Why is integer width so ambiguous in C/C++? (I am using "platform" as equivalent to CPU+OS+compiler).
int can be any width D wants it to be and everything works great so long as you're only calling D functions. The conflict comes when calling C functions, and there's nothing in the language for addressing this. Instead, it's a library issue. For example, Druntime's core.stdc.config defines "c_long" and "c_ulong" types for interfacing with C, since these types change width across 32 and 64-bit platforms. There's been no attempt to deal with odd-sized int or other types though. That just isn't an issue on common platforms.
Oct 21 2009
"Sean Kelly" <sean invisibleduck.org> wrote in message news:hbo3bv$2q25$1 digitalmars.com...AJ Wrote:How can/does D guarantee that "int" will always be 32 bits on all platforms? Does this mean that D won't work on some platforms? Why is integer width so ambiguous in C/C++? (I am using "platform" as equivalent to CPU+OS+compiler).
int can be any width D wants it to be and everything works great so long as you're only calling D functions. The conflict comes when calling C functions, and there's nothing in the language for addressing this. Instead, it's a library issue. For example, Druntime's core.stdc.config defines "c_long" and "c_ulong" types for interfacing with C, since these types change width across 32 and 64-bit platforms. There's been no attempt to deal with odd-sized int or other types though. That just isn't an issue on common platforms.
I had struct layout/size/alignment/member-alignment concerns.
Oct 21 2009