LLVM (clang) がなんかホットみたいだから、 OpenIndiana で clang をビルドしてやろうと思って、ビルドしてて何か不思議なエラーが大量にでるなと思ったら、変な定数が define されてた。
#include <cstdlib> int main(void) { return ES; }
$ g++ -o a a.cpp -Wl,-R/opt/gcc/4.8.2/lib $ ./a $ echo $? 2
#include <cstdlib> #define ES ES int main(void) { return ES; }
$ g++ -o a a.cpp -Wl,-R/opt/gcc/4.8.2/lib a.cpp:2:0: warning: "ES" redefined [enabled by default] #define ES ES ^ In file included from /usr/include/sys/ucontext.h:36:0, from /usr/include/sys/signal.h:245, from /usr/include/sys/procset.h:42, from /usr/include/sys/wait.h:43, from /usr/include/stdlib.h:38, from /opt/gcc/4.8.2/include/c++/4.8.2/cstdlib:72, from a.cpp:1: /usr/include/sys/regset.h:111:0: note: this is the location of the previous definition #define ES 2 ^ (以下略)
あんなところに定義されているのか。付近のソースを読んだところ、__EXTENSIONS__
を undef しておけば大丈夫だろう*2。
ちなみに Solaris Studio の C++ コンパイラ CC では cstdlib が stdlib.h を読み込む形になっていないだけでなく、__EXTENSIONS__
も定義していない様です。
$ CC -o a a.cpp "a.cpp", 行 4: エラー: ES は定義されていません. 1 個のエラーが検出されました.
PS: make clang-test で Abort が頻発しているので、再コンパイルだな。