c++ - Boost 是否使用合法的 C++ 预处理指令语法?

标签 c++ boost syntax c-preprocessor boost-preprocessor

我的(相对较旧的)C++ 编译器在 this 上卡住了Boost 中的文件,开头为:

# /* Copyright (C) 2001
#  * Housemarque Oy
#  * http://www.housemarque.com
#  *
#  * Distributed under the Boost Software License, Version 1.0. (See
#  * accompanying file LICENSE_1_0.txt or copy at
#  * http://www.boost.org/LICENSE_1_0.txt)
#  */
#

这真的是合法的 C++ 吗?预处理器标记的语法规则是什么?

最佳答案

是的,标准 §16 [cpp] 明确允许仅包含 # 和空格的行:

control-line:
   # include pp-tokens new-line
   # define identifier replacement-list new-line
   # define identifier lparen identifier-listopt) replacement-list new-line
   # define identifier lparen ... ) replacement-list new-line
   # define identifier lparen identifier-list, ... ) replacement-list new-line
   # undef identifier new-line
   # line pp-tokens new-line
   # error pp-tokensopt new-line
   # pragma pp-tokensopt new-line
   # new-line

请注意,在翻译阶段 3,即预处理器之前,注释会被空格替换。

关于c++ - Boost 是否使用合法的 C++ 预处理指令语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11912861/

相关文章:

c++ - C++不等待输入

c++ - 如何在 visual studio 中修复 'C2061 syntax error identifier ' 堆栈?

python - 如何解决该打印语句的对齐方式?

css - CSS block 中的未闭合引号

C++ wstring 如何从 NULL 终止的 wchar_t 数组分配

c++ - 有什么方法可以找出静态库是用 -fPIcflags编译的

c++ - 使用堆栈查看两个字符串是否相等

multithreading - 使用 CLR boost 线程

c++ - 自 1.55 以来 boost::bind/boost::function 的奇怪行为变化

c++ - interprocess::named_upgradable_mutex - 如果进程被杀死则保持锁定