我最近遇到了一些代码,如果没有这个arg,gcc就无法编译.我检查了gcc手册页,但没有找到这个特定的选项.我找到了XOPEN_SOURCE,但几乎没有解释它的作用.
有人可以详细说明吗?我知道-D_XOPEN_SOURCE可以设置为不同的值,这样400,600但什么的呢?
有人可以解释一下:
$ cat test.cpp
#include <string>
std::string div;
$ g++ -c test.cpp
$ g++ -std=c++11 -c test.cpp
test.cpp:2:13: error: 'std::string div' redeclared as different kind of symbol
In file included from /usr/include/c++/4.7.1/cstdlib:66:0,
from /usr/include/c++/4.7.1/ext/string_conversions.h:37,
from /usr/include/c++/4.7.1/bits/basic_string.h:2814,
from /usr/include/c++/4.7.1/string:54,
from test.cpp:1:
/usr/include/stdlib.h:787:14: error: previous declaration of 'div_t div(int, int)'
$
Run Code Online (Sandbox Code Playgroud)
对于C++ 11模式,div符号是否也不应该在std命名空间中?或者它是我的系统特有的东西?