Why __func__, __FUNCTION__ and __PRETTY_FUNCTION__ aren't preprocessor macros?

后端 未结 1 1310
北海茫月
北海茫月 2020-12-28 14:05

I\'ve just noticed that __func__, __FUNCTION__ and __PRETTY_FUNCTION__ aren\'t treated as preprocessor macros and they\'re not mention

相关标签:
1条回答
  • 2020-12-28 14:21

    Expanding __func__ at preprocessing time requires the preprocessor to know which function it's processing. The preprocessor generally doesn't know that, because parsing happens after the preprocessor is already done.

    Some implementations combine the preprocessing and the parsing, and in those implementations, it would have been possible for __func__ to work the way you'd like it to. In fact, if I recall correctly, MSVC's __FUNCTION__ works like that. It's an unreasonable demand on implementations that separate the phases of translation though.

    0 讨论(0)
提交回复
热议问题