Search code examples
c++visual-c++macroslogic

What is the type of the __LINE__ macro in C++


What is the type of the __LINE__ macro in C++?


Solution

  • C++03 §16.8p1:

    __LINE__ The line number of the current source line (a decimal constant).

    This will either be int, or if INT_MAX (which is allowed to be as little as 32,767) is not big enough (… I won't ask …), then it will be long int. If it would be bigger than LONG_MAX, then you have undefined behavior, which, for once, is not a problem worth worrying about in a file of at least 2,147,483,647 lines (the minimum allowed value for LONG_MAX).

    The same section also lists other macros you may be interested in.