[英]C++ preprocessor removes whitespace in calls to variadic macros (Solaris Studio 12.3)
The C++ preprocessor of Oracle Solaris Studio 12.3 removes whitespace completely when expanding __VA_ARGS__
. 在扩展
__VA_ARGS__
时,Oracle Solaris Studio 12.3的C ++预处理器会完全删除空白。
Can anybody confirm this behaviour on their system? 有人可以在他们的系统上确认这种行为吗? Is it a known compiler bug?
它是一个已知的编译器错误吗? Are there any workarounds for this problem?
这个问题有没有解决方法?
To illustrate, here is a simple test program, vaargs.c
: 为了说明,这是一个简单的测试程序,
vaargs.c
:
#include <stdio.h>
#define PRINT(...) printf("%s\n", #__VA_ARGS__)
int main()
{
PRINT(hello world);
return 0;
}
The C preprocessor works as expected: C预处理器按预期工作:
$ cc vaargs.c -o vaargs && ./vaargs
hello world
$ cc -V
cc: Sun C 5.12 SunOS_i386 2011/11/16
But the C++ preprocessor removes the space between "hello" and "world": 但是C ++预处理器删除了“hello”和“world”之间的空格:
$ CC vaargs.c -o vaargs && ./vaargs
helloworld
$ CC -V
CC: Sun C++ 5.12 SunOS_i386 2011/11/16
This is a compiler bug, as per N3337 16.3.2 (cpp.stringize) p2 (the rest of the quote is snipped): 这是一个编译器错误,根据N3337 16.3.2(cpp.stringize)p2(引用的其余部分被剪切):
A character string literal is a string-literal with no prefix.
字符串文字是一个没有前缀的字符串文字 。 If, in the replacement list, a parameter is immediately preceded by a
#
preprocessing token, both are replaced by a single character string literal preprocessing token that contains the spelling of the preprocessing token sequence for the corresponding argument.如果在替换列表中,参数前面紧跟
#
预处理标记,则它们都被单个字符串文字预处理标记替换,该标记包含相应参数的预处理标记序列的拼写。 Each occurrence of white space between the argument's preprocessing tokens becomes a single space character in the character string literal.参数的预处理标记之间每次出现的空格都会成为字符串文字中的单个空格字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.