为什么在 C++ 宏扩展为注释时会出现 "Expected a declaration" 错误?
Why do I get an "Expected a declaration" error on C++ macro expanding into a comment?
我有以下宏:
#define DEFINE_EXPORT_MODULE(__module__) /##*Exported by __module__*/
如果我这样使用它:DEFINE_EXPORT_MODULE(foo)
它会正确扩展为 /*Exported by foo*/
但我仍然收到 E0169 错误:"Expected a declaration."
怎么了?
编辑:这是我在代码中使用它的方式。
#define DEFINE_EXPORT_MODULE(__module__) /##*Exported by __module__*/
DEFINE_EXPORT_MODULE("foo.dll") //this produces the error.
void Function(void);
粘贴运算符的结果必须是展开宏后的有效标记。
尝试创建评论失败,因为评论在预处理开始前被删除。
查看reference。
我有以下宏:
#define DEFINE_EXPORT_MODULE(__module__) /##*Exported by __module__*/
如果我这样使用它:DEFINE_EXPORT_MODULE(foo)
它会正确扩展为 /*Exported by foo*/
但我仍然收到 E0169 错误:"Expected a declaration."
怎么了?
编辑:这是我在代码中使用它的方式。
#define DEFINE_EXPORT_MODULE(__module__) /##*Exported by __module__*/
DEFINE_EXPORT_MODULE("foo.dll") //this produces the error.
void Function(void);
粘贴运算符的结果必须是展开宏后的有效标记。
尝试创建评论失败,因为评论在预处理开始前被删除。
查看reference。