Behavior of __LINE__ in inline functions

主宰稳场 提交于 2019-12-04 23:10:55

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!