我的(相对较旧的)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/