Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the type of size_t is uint in 64-bit Windows 7?

Tags:

d

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!

like image 233
Nan Xiao Avatar asked Jan 04 '15 09:01

Nan Xiao


People also ask

Is Size_t 32 or 64-bit?

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.

Is unsigned long 32 or 64-bit?

Windows: long and int remain 32-bit in length, and special new data types are defined for 64-bit integers.

Is Size_t signed or unsigned?

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.

Is unsigned long long 64 bits?

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++.


1 Answers

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.)

like image 137
Vladimir Panteleev Avatar answered Sep 25 '22 19:09

Vladimir Panteleev