D:\ZBY\CodeBase\eigen-3.4.0\Eigen\src\Core\MathFunctions.h:400: error: conflicting declaration of C function 'long long int std::abs(long long int)' EIGEN_USING_STD(abs); ^
时间: 2024-01-24 22:18:49 浏览: 22
这个错误是因为在 `MathFunctions.h` 文件中有一行代码 `EIGEN_USING_STD(abs);`,它会使用 `std` 命名空间中的 `abs()` 函数。但是,在 C++11 标准中,`std::abs()` 函数被重载为接受不同类型的参数,包括 `long long int`。因此,在编译器中出现了冲突的声明。
要解决这个问题,你可以尝试以下几种方法:
1. 升级你的编译器到支持 C++11 标准的版本。
2. 修改 `MathFunctions.h` 文件中的代码,将 `EIGEN_USING_STD(abs);` 改为 `using std::abs;`。这样可以避免使用 `std` 命名空间中的 `abs()` 函数,而是直接使用全局命名空间中的 `abs()` 函数。
3. 在使用 `MathFunctions.h` 文件的代码中,添加 `#undef abs` 宏定义来取消 `std::abs()` 函数的定义。这样可以避免冲突的声明。但是,这种做法可能会影响到其他代码中对 `abs()` 函数的使用,因此需要谨慎使用。
相关问题
D:\ZBY\CodeBase\eigen-3.4.0\Eigen\src\Core\MathFunctions.h:389: error: conflicting declaration of C function 'long long int std::abs(long long int)' EIGEN_USING_STD(abs); ^
这个错误可能是由于在使用Eigen库时,Eigen库的MathFunctions.h头文件中的`EIGEN_USING_STD(abs)`语句与其他头文件中的`abs`函数发生了冲突。这通常是因为系统头文件中的`abs`函数与Eigen库中的`abs`函数重名而引起的。
解决这个问题可以尝试以下方法:
1. 在使用Eigen库之前,加上`#define EIGEN_DONT_VECTORIZE`宏定义,禁止Eigen库向量化,这样就可以避免`EIGEN_USING_STD(abs)`语句与系统头文件中的`abs`函数冲突。
2. 在使用Eigen库之前,添加`#include <cmath>`头文件,这样可以确保使用的是C++标准库中的`abs`函数。
3. 将Eigen库中的`MathFunctions.h`头文件中的`EIGEN_USING_STD(abs)`语句注释掉,然后手动调用C++标准库中的`abs`函数。
希望以上方法能够帮到你解决问题。
D:\ZBY\CodeBase\eigen-3.4.0\Eigen\src\SVD\BDCSVD.h:416: error: conflicting declaration of C function 'long long int std::abs(long long int)' using std::abs; ^
这个错误是因为在你的代码中使用了 `std::abs` 函数,而该函数已经被 `BDCSVD.h` 文件中的另一个声明所覆盖。解决方法有两种:
1. 使用 `std::fabs` 代替 `std::abs`。
2. 在 `#include` `BDCSVD.h` 之前加上 `#undef abs`,这样可以取消 `BDCSVD.h` 中对 `abs` 的定义。