重新定义C关键字是否合法?
作者:互联网
在本周的Guru的this article中,有人说:#define保留字是违法的.这是真的?我找不到常规,我已经看过程序员重新定义新的,例如.
解决方法:
17.4.3.1.1宏名[lib.macro.names]
1 Each name defined as a macro in a header is reserved to the implementation for any use if the translation unit includes the header.164)
2 A translation unit that includes a header shall not contain any macros that define names declared or defined in that header. Nor shall such a translation unit define macros for names lexically identical to keywords.
顺便说一下,new是一个操作符,用户可以通过提供自己的版本来重载(替换)它.
标签:c,c-preprocessor,standards,keyword 来源: https://codeday.me/bug/20190917/1810200.html