#为""定义宏;静态";针对不同的上下文
#define macros for "static" for different contexts
我想区分"静态";关键字。可能存在哪些缺点
#define common static // class member
#define intern static // linkage
从技术和语义角度来看。
如果你使用这种方法,如果有人不知道这意味着什么,就会迷失方向。如果您真的想使用宏(请阅读:https://google.github.io/styleguide/cppguide.html#Preprocessor_Macros),我建议您使用UPPER_CASE:
#define COMMON static // class member
#define INTERN static // linkage
如果你只使用大写字母,看到你代码的人就会知道,这是宏。谷歌C++风格指南鼓励使用这种风格(https://google.github.io/styleguide/cppguide.html#Macro_Names)。
从技术角度来看,我认为没有区别,因为C++编译器不会看到区别,因为预处理器用static
替换了common
和intern
。
相关文章:
- #为""定义宏;静态";针对不同的上下文
- 与互斥锁相比,旋转锁可以保证上下文切换
- 线程,如果else语句,都是错误的上下文切换后,会发生什么
- 为什么我不能使用 EGL 创建无头 OpenGl 上下文?
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- 为什么在逗号分隔符上下文中将预增量的结果强制转换为void
- 错误"Could not find Boost"(缺少:上下文标头)
- 使用 mod_gsoap 部署服务时,如何在 Gsoap 中更改 soap 上下文的模式?
- 将有状态的 lambda 传递到 C 样式函数中,而无需上下文参数
- 安排带有上下文的协同程序
- 我的文件无法正常工作,无法从C++文件中读取上下文
- DCMTK 了解"DIMSE 没有有效的演示上下文 ID"错误
- 具有std::initializer_list参数的非成员函数(/non构造函数上下文)的重载解析
- antlr 规则上下文是否可以独立于目标
- OpenGL 调试上下文警告 -"将使用视频内存作为缓冲区异议的来源
- MSVC 在不知道类型的情况下评估上下文(和错误)
- 为什么 Perf 具有如此高的上下文切换?
- 非推导上下文,如标准库中的"boost::mpl::identity:<T>:type"?
- 使用 std::size 来自非 const 上下文
- 如何使用IExecuteCommand和动词在上下文菜单外壳扩展中显示本地化文本和自定义图标?