I am a newbie of programming D
. After reading Fundamental Types, I decide to check the size_t
type in my 64
-bit Windows 7 OS. The code is like this:
import std.stdio;
void main()
{
writeln("Type: ", size_t.stringof);
writeln("Size: ", size_t.sizeof);
}
After executing, the output is:
Type: uint
Size: 4
Per my understanding, the type of size_t
should be ulong on 64
-bit OS.
Could anyone give any clue? Thanks very much in advance!
size_t type is a base unsigned integer type of C and C++ language. It is the type of the result returned by sizeof operator. The type's size is chosen so that it can store the maximum size of a theoretically possible array of any type. On a 32-bit system size_t will take 32 bits, on a 64-bit one 64 bits.
Windows: long and int remain 32-bit in length, and special new data types are defined for 64-bit integers.
size_t is the unsigned integer type of the result of sizeof , _Alignof (since C11) and offsetof, depending on the data model. The bit width of size_t is not less than 16.
In this article, we will discuss the unsigned long long int data type in C++. It is the largest (64 bit) integer data type in C++.
The bitness of your program is distinct from the bitness of the OS or the compiler.
With DMD, to create a 64-bit executable, specify the -m64
switch. By default, DMD will create programs with the same bitness as the compiler, and the Windows package includes a 32-bit compiler. (If you wish, you can also build a 64-bit compiler from source code, but this will not affect how it builds either 32-bit or 64-bit programs.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With