在visual studio中运行C++时,我尝试编写一个简单的Hello World命令。然而,当我这样做的时候,我总是得到这个问题。
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\math.h(1,1): warning C4821: Unable to determine Unicode encoding type, please save the file with signature (BOM)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cstdlib(24,18): error C2039: 'fabs': is not a member of '`global namespace''
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cstdlib(24,22): error C3861: 'fabs': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cstdlib(28,18): error C2039: 'fabsf': is not a member of '`global namespace''
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cstdlib(28,23): error C3861: 'fabsf': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cstdlib(32,18): error C2039: 'fabsl': is not a member of '`global namespace''
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cstdlib(32,23): error C3861: 'fabsl': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cmath(26,47): warning C4244: 'argument': conversion from 'double' to 'int', possible loss of data
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cmath(30,18): error C2039: 'acosf': is not a member of '`global namespace''
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cmath(30,23): error C3861: 'acosf': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cmath(34,18): error C2039: 'acoshf': is not a member of '`global namespace''
(etc)#include <iostream>
int main()
{
std::cout << "Hello World!\n";
return 0;
}问题似乎来自cmath头文件内部的这些行。
_NODISCARD _Check_return_ inline float acos(_In_ float _Xx) noexcept /* strengthened */ {
return _CSTD acosf(_Xx);
}
_NODISCARD _Check_return_ inline float acosh(_In_ float _Xx) noexcept /* strengthened */ {
return _CSTD acoshf(_Xx);
}
_NODISCARD _Check_return_ inline float asin(_In_ float _Xx) noexcept /* strengthened */ {
return _CSTD asinf(_Xx);
}我应该注意到,这些错误存在于cmath头文件的大部分,而不仅仅是这里显示的那些错误,但我认为包含数百个错误没有什么用处。
这与Visual Studio依赖关系有关吗?有什么方法可以避免这个错误吗?
我正在进行一个干净的visual studio安装。
发布于 2020-01-21 04:56:52
在经历了一些痛苦之后,我找到了问题所在。基本上,我的math.h文件已经损坏,并且刚刚发布了NULLS。
我进入了windows工具包中的UCRT文件,并从以前的发行版复制了一个math.h文件。现在一切都正常了。
同样的技巧也适用于进入您的项目属性,并将您的SDK版本更改为与当前版本分开的版本。
https://stackoverflow.com/questions/59828776
复制相似问题