gpt4 book ai didi

c++ - 标识符和宏有什么区别?

转载 作者:行者123 更新时间:2023-11-28 04:37:11 25 4
gpt4 key购买 nike

当我们编写预处理器指令时,例如:

#define PI 3.1416    
// Is PI is a macro or an identifier and how do we distinguish
// one from another?

最佳答案

在您的示例中,PI 既是宏又是标识符。 “标识符”粗略地说是指定名称的语法的正式术语。宏、函数、命名空间、类型、变量都有名称,所有这些名称都是使用标识符指定的。从上下文中应该清楚 PI 是作为宏还是作为标识符:

The above defines PI as 3.1416.

这里用来引用宏。

The PI following the #define specifies the name of the macro.

这里用来指代标识符:用来指代源代码中指定宏名的两个字符。

关于c++ - 标识符和宏有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51076036/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com