stdio.hとmpi.hの順番によるエラー
mpiccとかmpiiccとかで以下のようなプログラムをコンパイルする時、stdio.hとmpi.hの順番を変えろ、というエラーが出る事がある。
#include <stdio.h> #include <mpi.h> int main(void){ printf("Hello\n"); }
$ mpiicc test.cc /opt/intel/impi/4.1.0.030/intel64/include/mpicxx.h(95): catastrophic error: #error directive: "SEEK_SET is #defined but must not be for the C++ binding of MPI. Include mpi.h before stdio.h" #error "SEEK_SET is #defined but must not be for the C++ binding of MPI. Include mpi.h before stdio.h" ^ compilation aborted for test.cc (code 4)
指示通り、mpi.hとstdio.hを入換えても良いのだが、大きなコードでそれをやるのは面倒。-DMPICH_IGNORE_CXX_SEEKオプションをつけてコンパイルすると、このエラーは出ない。
$ mpiicc -DMPICH_IGNORE_CXX_SEEK test.cc