Search code examples
cgccsize-type

gcc compiler __SIZE_TYPE__


I'm curious about the variable __SIZE_TYPE__ which is predefined by gcc compiler.

Suppose that I coded like following sentence in C

typedef __SIZE_TYPE__ size_t; 

Is there any possibility that an error occurs when I use another C compiler excluding gcc? Do all C compilers have the variable __SIZE_TYPE__?


Solution

  • Yes, it is possible that an error occurs as soon as you use any identifier with double underscore. See the C standard 7.1.3:

    All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use.

    As for __SIZE_TYPE__ that's apparently a gcc identifier. I don't think any other compiler uses it, but there are no guarantees. Another compiler is perfectly free to use the same identifier even for an entirely different purpose.