Why can't I qualify unsigned aliases?

I port my code from Windows to Linux. There is no type __int64 on Linux, so I tried to define it myself using an alias. My code is as follows:

#include <cstdint>

#if !defined(__int64)
typedef int64_t __int64;
#endif

int main(int argc, char** argv)
{
    unsigned __int64 ii64 = 0; // Error
    return 0;
};

When I compiled it, I got the following error:

main.cpp: In the function 'int main (int, char **): main.cpp: 10: 20: error: expected initializer before' ii64

I know that I can replace "unsigned __int64" with "uint64_t" or define a new type, but why can't the previous code compile?

+4
source share
4 answers

See standard 7.1.6 / 2:

, - decl-specifier-seq type-specifier-seq trailing-type-specifier-seq. :

unsigned char, long, short int.

, , unsigned typedef, , .

, , __int64 , . int64_t uint64_t.

+4

typedef . ! , .

unsigned int, , const int. const - . , , . unsigned quialifier. unsigned int - .

+2

, "unsigned int" - , "unsigned int64_t" - .

0

, , unsiged int64_t. . #define __int64 int, , unsigned int.

0
source

All Articles