今天给程序增加了几个其它库的头文件,结果编译的时候出现了一屏幕的报错,找到第一个报错的地方,提示min调用出错,像是重定义了,新增加的头文件A.h(暂时这么叫它)中的确有重新define了min,
#ifndef min
#define min(a,b) ((a)<(b)? a:b)
#endif
并且在这个头文件A.h中有使用,于是把这个地方define的min修改成其它名字编译就通过了。但是还有一点不明白的是,我的程序中.cpp也有使用min却对编译没有影响,并且如果我把A.h中对min的define去掉,再编译就会提示min找不到对应的定义。
附录:编译报错
/usr/local/gcc-5.5/bits/stl_algobase.h:243:56: 错误:宏“min”传递了 3 个参数,但只需要 2 个
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
/usr/local/gcc-5.5/bits/stl_algobase.h: 在全局域:
/usr/local/gcc-5.5/bits/stl_algobase.h:195:5: 错误:expected unqualified-id before ‘const’
min(const _Tp& __a, const _Tp& __b)
^
/usr/local/gcc-5.5/bits/stl_algobase.h:195:5: 错误:expected ‘)’ before ‘const’
/usr/local/gcc-5.5/bits/stl_algobase.h:195:5: 错误:expected ‘)’ before ‘const’
/usr/local/gcc-5.5/bits/stl_algobase.h:195:5: 错误:expected initializ