Behavior of __LINE__ in inline functions Behavior of __LINE__ in inline functions c c

Behavior of __LINE__ in inline functions


In C and C++, macros aren't (for the most part) evaluated with any knowledge of the actual code and are processed before the code (hence the name "preprocessor"). Therefore, __FILE__ would evaluate to "file.h", and __LINE__ would evaluate to the line number corresponding to the line on which SYSTEM_FAILURE appears in file.h.


Since macros are replaced by their definitions before compilation, the __LINE__ will contain the actual line of the file in which you used the macro. Inlining will not affect this behaviour at all.


__LINE__ will be the line of the header file since the preprocessor will evaluate it before the compiler will ever see it.