Ben*_*enC 3 c++ gcc c-preprocessor
在为CUDA编译器进行错误报告时,我最终在gcc的预处理步骤中发现了这种奇怪的行为。我目前使用gcc 4.8.2。
#include <assert.h>
int main()
{
int a = 1;
assert (a >= 0);
assert (a
>= 0);
}
Run Code Online (Sandbox Code Playgroud)
gcc -E -x c ++ -m64 -g -o“ test.cpp4.ii”“ test.cpp”
# 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__))
;
Run Code Online (Sandbox Code Playgroud)
多行断言似乎被不同地处理,从而导致了这些# 7 "test.cpp" 3 4行。这到底是什么意思?
显然,gcc 4.7给出了# 7 "test.cpp"(没有最后两个数字)。
| 归档时间: |
|
| 查看次数: |
561 次 |
| 最近记录: |