我正在尝试将Quadlods 移植到 SmartOS。它在 Linux 和 DragonFly BSD 上编译和运行。我还没有尝试在 Windows 上运行它,但是使用 xy 类和 isfinite 方法的其他程序可以在 Windows 上编译和运行。但是,在 SmartOS 上编译它,我得到这个错误:
[ 15%] Building CXX object CMakeFiles/quadlods.dir/filltest.cpp.o
In file included from /usr/include/math.h:36,
from /opt/local/gcc9/include/c++/9.3.0/bits/std_abs.h:40,
from /opt/local/gcc9/include/c++/9.3.0/cstdlib:77,
from /opt/local/gcc9/include/c++/9.3.0/ext/string_conversions.h:41,
from /opt/local/gcc9/include/c++/9.3.0/bits/basic_string.h:6493,
from /opt/local/gcc9/include/c++/9.3.0/string:55,
from /opt/local/gcc9/include/c++/9.3.0/stdexcept:39,
from /opt/local/gcc9/include/c++/9.3.0/optional:38,
from /opt/local/gcc9/include/c++/9.3.0/bits/node_handle.h:39,
from /opt/local/gcc9/include/c++/9.3.0/bits/stl_tree.h:72,
from /opt/local/gcc9/include/c++/9.3.0/map:60,
from /home/phma/src/quadlods/quadlods.h:27,
from /home/phma/src/quadlods/filltest.h:25,
from /home/phma/src/quadlods/filltest.cpp:26:
/home/phma/src/quadlods/xy.h:35:8: error: expected ')' before '!=' token
35 | bool isfinite() const;
| ^~~~~~~~
定义宏的文件,导致这个奇怪的错误,是 /usr/include/iso/math_c99.h:
#define isfinite(x) (__builtin_isfinite(x) != 0)
头文件中的类定义是
class xy
{
public:
xy(double e,double n);
xy();
double getx() const;
double gety() const;
double length() const;
bool isfinite() const;
bool isnan() const;
friend xy operator+(const xy &l,const xy &r);
friend xy operator+=(xy &l,const xy &r);
friend xy operator-=(xy &l,const xy &r);
friend xy operator-(const xy &l,const xy &r);
friend xy operator-(const xy &r);
friend xy operator*(const xy &l,double r);
friend xy operator*(double l,const xy &r);
friend xy operator/(const xy &l,double r);
friend xy operator/=(xy &l,double r);
friend bool operator!=(const xy &l,const xy &r);
friend bool operator==(const xy &l,const xy &r);
friend xy turn90(xy a);
friend xy turn(xy a,int angle);
friend double dist(xy a,xy b);
protected:
double x,y;
};
是否可以在不重命名方法的情况下在 SmartOS 上进行编译?我想过取消定义 isfinite 宏,但是在另一个程序(不是 Quadlods,其头文件只有 quadlods.h)中,xy 类位于库的头文件中。此外,isfinite 方法调用 std::isfinite。