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); ^
时间: 2024-01-24 16:18:36 浏览: 16
这个错误是由于 `abs` 函数被重复定义导致的。这个错误通常是由于引入了多个头文件导致的。你可以尝试在使用 `abs` 函数的地方加上命名空间 `std::`,例如使用 `std::abs` 而不是 `abs`。或者你可以尝试使用 `#undef abs` 来取消前面的定义。如果这些方法都无法解决问题,建议你检查一下头文件的引入情况,看看是否有重复引入的情况。
相关问题
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); ^
这个错误是因为在 `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\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` 的定义。