【问题标题】:error C2039: 'fabs': is not a member of '`global namespace''错误 C2039:“fabs”:不是“全局命名空间”的成员
【发布时间】:2020-05-24 17:30:54
【问题描述】:

我的项目编译良好,即使完全重建,然后我修改了对话框资源中的单个参数,现在它甚至更改回参数都无法编译,我有很多错误,首先是:

1>C:\Program Files\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cstdlib(24,18): error C2039: 'fabs': is not a member of '`global namespace''
1>C:\Program Files\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cstdlib(24,22): error C3861: 'fabs': identifier not found
1>C:\Program Files\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cstdlib(28,18): error C2039: 'fabsf': is not a member of '`global namespace''
1>C:\Program Files\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cstdlib(28,23): error C3861: 'fabsf': identifier not found
1>C:\Program Files\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cstdlib(32,18): error C2039: 'fabsl': is not a member of '`global namespace''
1>C:\Program Files\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cstdlib(32,23): error C3861: 'fabsl': identifier not found

cmath 中也有:

1>C:\Program Files\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cmath(31,18): error C2039: 'acosf': is not a member of '`global namespace''
1>C:\Program Files\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cmath(31,23): error C3861: 'acosf': identifier not found
1>C:\Program Files\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cmath(35,18): error C2039: 'acoshf': is not a member of '`global namespace''
1>C:\Program Files\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cmath(35,24): error C3861: 'acoshf': identifier not found

因为它位于 Microsoft 文件中,所以我看不出我能做什么。

编辑:如果我在 cmath 中选择“转到定义”,似乎所有这些函数都没有声明,因为 _CRT_FUNCTIONS_REQUIRED 没有被定义,也许它可以帮助。

【问题讨论】:

  • 你还有其他错误还是只有这个?有时,如果您遇到简单的代码问题,编译器将无法工作并引发大量其他错误
  • 在这些之前我没有错误,而且只有在 cstdlib 和 cmath 中。
  • 如果您使用没有std:: 作用域的<cmath> 函数,那么在此之前您应该有错误。如果碰巧你没有那没关系。修复问题。
  • 注意:你可能想使用std::fabs而不是从C继承的全局::fabs。C版本总是采用double,所以对于floatlong double你'将支付晋升或截断的费用。不过,std::fabs 版本针对不同的类型进行了重载。
  • @Entretoize 在对话框 resource 中更改任何内容都不会触发 C++ 代码的重新编译,因此您必须还在其他地方更改了其他内容。尝试找出“其他东西”是什么以及在哪里。

标签: c++ visual-studio winapi


【解决方案1】:

由于修改资源后出现的问题,我发现fabs 未声明,因为_CRT_FUNCTIONS_REQUIRED 未设置为1,我检查了我的resource.h 文件(来自原始项目)并看到很多定义行设置和一个包含#define _CRT_FUNCTIONS_REQUIRED 0

我注释掉了所有的行并取消了缺少的定义,我能够编译。

【讨论】:

    猜你喜欢
    • 2013-05-17
    • 1970-01-01
    • 1970-01-01
    • 2015-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多