C++what is the type of the __LINE__ macro

prabhakaran picture prabhakaran · Feb 22, 2011 · Viewed 9.6k times · Source

As you may see from my other questions many of you may already got the answer for this. Can you please share that knowledge to me?

Answer

Fred Nurk picture Fred Nurk · Feb 22, 2011

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.