gcc 预处理的表单哈希符号 + 数字"# 1"输出行是什么意思?
What do gcc preprocessed output lines of form hash sign + digit "# 1" mean?
在为CUDA的编译器做错误报告时,我在gcc的预处理步骤中发现了这种奇怪的行为。我目前使用的是gcc 4.8.2。
测试文件:Test.cpp
#include <assert.h>
int main()
{
int a = 1;
assert (a >= 0);
assert (a
>= 0);
}
命令
gcc-E-x c++-m64-g-o"test.cpp4.ii"test.cpp"
结果文件:test.cpp4.ii
# 2 "test.cpp" 2
int main()
{
int a = 1;
((a >= 0) ? static_cast<void> (0) : __assert_fail ("a >= 0", "test.cpp", 6, __PRETTY_FUNCTION__));
((a >= 0) ? static_cast<void> (0) : __assert_fail ("a >= 0",
"test.cpp"
# 7 "test.cpp" 3 4
,
8
# 7 "test.cpp" 3 4
, __PRETTY_FUNCTION__))
;
多行断言的处理方式似乎有所不同,从而产生了这些# 7 "test.cpp" 3 4
行。这到底是什么意思?
更新
显然,gcc 4.7给出了# 7 "test.cpp"
(没有最后两个数字)。
它看起来像线条标记。正如您可能已经注意到的,原始文件和预处理文件中的行号之间没有微不足道的关系。预处理输入中的# 7
表示下一行的来源是原始文件中的第7行(名为test.cpp)
3 4
是标志,表示"从系统头进行宏扩展"和extern "C"
GCC文档
相关文章:
- 为对象分配整数.输出将是什么?
- 以下与指针相关的代码的输出是什么?
- 从 c++ 中的实例化进程获取输出的可靠方法是什么?
- 我的输出结果是 0 英寸C++.可能是什么问题
- 以下程序在 c++ 中的输出是什么?
- 任何人都解释下面的代码,它的输出是什么?
- 这段代码的输出是什么,它在构造函数中使用 strcpy?
- 以下代码的输出是什么(答案因差异编译器而异)
- 该代码将如何工作以及输出的输出是什么
- 这里发生了什么,还有输出是什么?(无线索)
- 此代码的输出是什么?我在这里错过了什么吗?
- 假设动态范围,以下C++程序的输出是什么
- "cout << (a, b)"的输出是什么,为什么?
- ".hidden"输出对象转储 -t 的输出是什么意思?
- c中的fork()命令——这段简单代码的输出是什么
- 例外C++,我只是不明白为什么输出是什么
- 以下代码的输出是什么?
- 这段代码的输出是什么?
- 这个Valgrind输出是什么意思?
- 下面代码的输出是什么?