Why is size_t intrinsically defined in visual studio c++ x64

Viewed 68

This code compiles with no headers, implying that size_t is intrinsically defined as unsigned long long:

int main()
{
    size_t i = -1;  // i is 18446744073709551615
}

But this Q&A says that std::size_t is defined in <cstddef> and may or may not be included in the global namespace.

However, I'm not including any headers, so where is this defined?

Further, if I defined it as a signed int, it also works! Note:
@user17732522 points out this is local so OK. When put in global it fails to compile.

int main()
{
    typedef long long int size_t;
    size_t i = -1;  // i is 1
}

Is this a bug, or some odd extension in Visual C++?

0 Answers
Related