次のコードがあります。
#ifndef min
#define min(a,b) (((a)< (b)) ? (a) : (b))
#endif
int test(){
return min(0,1);
}
これは問題なく動作します。ただし、ヘッダー ファイルをインクルードすると (グラフ データベースから、このヘッダー ファイルの内容はhttp://www.sparsity-technologies.com/dexで確認できます)、コンパイラは min が定義されていないと不平を言います。 Dex.h は、私のマルコ定義の効果をキャンセルしました。
ただし、Dex.h には未定義のステートメントは含まれていません。マクロ定義は、実際には別のヘッダー ファイルに含まれているため、移動できませんでした。
何が問題で、どうすればよいですか?
#ifndef min
#define min(a,b) (((a)< (b)) ? (a) : (b))
#endif
#include "gdb/Dex.h"
int test(){
return min(0,1);
}
私が得るコンパイルエラーは次のとおりです。
test.c:9:16: error: 'min' was not declared in this scope