D:\ZBY\CodeBase\eigen-3.4.0\Eigen\src\LU\FullPivLU.h:715: error: conflicting declaration of C function 'long long int std::abs(long long int)' using std::abs; ^
时间: 2024-01-24 11:16:46 浏览: 104
这个错误是因为在你的代码中使用了 `std::abs` 函数,但是它与 `long long int` 类型存在冲突。解决这个问题的方法是使用 `<cmath>` 头文件中的 `llabs` 函数来代替 `std::abs` 函数,`llabs` 函数可以处理 `long long int` 类型的整数。
你只需要将代码中的 `std::abs` 改为 `llabs` 即可,例如:
```
long long int x = -12345;
long long int y = llabs(x);
```
如果你需要使用 `std::abs` 函数来处理其他类型的数据,你可以使用类型转换来解决冲突,例如:
```
int x = -12345;
long long int y = std::abs(static_cast<long long int>(x));
```
相关问题
D:\ZBY\CodeBase\eigen-3.4.0\Eigen\src\LU\FullPivLU.h:332: error: conflicting declaration of C function 'long long int std::abs(long long int)' using std::abs; ^
这个错误是因为在 FullPivLU.h 文件中使用了 `using std::abs`,而 `std::abs` 与 C 语言的 `abs` 函数重名了,导致冲突。解决这个问题的方法是使用命名空间 `std::` 来明确使用 C++ 标准库中的 `abs` 函数,而不是使用 `using` 语句。你可以在 FullPivLU.h 文件中将 `using std::abs` 改为 `using namespace std;` 或者直接使用 `std::abs` 替代原来的 `abs`。
D:\ZBY\CodeBase\eigen-3.4.0\Eigen\src\SVD\SVDBase.h:150: error: conflicting declaration of C function 'long long int std::abs(long long int)' using std::abs; ^
这个错误可能是因为您在代码中使用了 `std::abs` 函数,但是有另一个名为 `abs` 的函数与其冲突了。建议您使用 `std::abs` 代替 `abs`,或者使用 `using namespace std;` 来避免命名冲突。例如:
```cpp
#include <iostream>
#include <cmath>
using namespace std;
int main() {
long long int x = -123456789;
cout << abs(x) << endl; // 冲突
cout << std::abs(x) << endl; // 使用 std::abs
return 0;
}
```
如果您仍然想使用 `abs` 函数,您可以将其重命名为其他名称,如:
```cpp
#include <iostream>
#include <cmath>
namespace mymath {
using std::abs;
}
int main() {
long long int x = -123456789;
cout << abs(x) << endl; // 冲突
cout << mymath::abs(x) << endl; // 重命名为 mymath::abs
return 0;
}
```
阅读全文
相关推荐
















