在C/C ++预处理器中,在其自己的行上加一个井号/井号(#)的目的是什么? [英] What is the purpose of a single pound/hash sign (#) on its own line in the C/C++ preprocessor?
问题描述
我一直在查看 Boost 库的源代码,并且我已经注意到通常是单磅符号,没有附加任何预处理程序指令.我通读了GCC预处理程序手册和规格指南,但找不到任何东西.
I have been looking at the Boost libraries source code, and I have noticed that often there are single pound signs without any preprocessor directives attached to them. I read through the GCC preprocessor manual and specification guide and can't find anything about it.
(1) #ifndef BOOST_CONFIG_HPP
(2) # include <boost/config.hpp>
(3) #endif
(4) #
(5) #if defined(BOOST_HAS_PRAGMA_ONCE)
(6) # pragma once
(7) #endif
在第4行上,井号后面没有任何内容.这有什么作用?它是在C预处理程序(CPP)规范中定义的吗?
On line 4, there is nothing after the pound sign. What effect does this have? Is it defined in the C preprocessor (CPP) specification?
由于Boost是跨平台的库,因此我认为任何CPP都应正确解析它.在整个代码中具有随机的磅/哈希符号会产生什么影响/副作用?
As Boost is a cross-platform library, I would assume that any CPP should parse it correctly. What would the effect/side-effects be of having random pound/hash signs throughout the code?
推荐答案
#
单独在一行上根本没有任何作用.我认为它是用于美学价值的.
A #
on its own on a line has no effect at all. I assume it's being used for aesthetic value.
C标准说:
6.10.7空指令
语义
形式的预处理指令
# new-line
没有效果.
C ++标准说了同样的话:
The C++ standard says the same thing:
16.7空指令[cpp.null]
形式的预处理指令
# new-line
没有效果.
这篇关于在C/C ++预处理器中,在其自己的行上加一个井号/井号(#)的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!