gpt4 book ai didi

c++ - Windows SDK 7.1 编译器上的 yvals.h C4514 警告

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:36:09 25 4
gpt4 key购买 nike

我正在使用 cl.exe 版本 _MSC_FULL_VER == 160030319 进行编译,警告级别为 4。我收到此警告:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\yvals.h(773) : warning C4514: 'std::_Mutex::_Mutex' : unreferenced inline function has been removed

这段源码是什么:

__thiscall _Mutex(_Uninitialized)
{ // do nothing
}

yvals.h 包含在 stdint.h 中,我是这样包含的:

#pragma warning(disable:4514)

#include <stdint.h>

#pragma warning(default:4514)

但它仍然没有摆脱警告。我在这里做错了什么吗?

最佳答案

我找到了答案 here .有人将其报告为错误,但它已按设计关闭。答案是直到翻译单元结束时才会发出警告。引用:

Thanks for reporting this issue. I've resolved it as By Design because the 4514 and 4710 warnings are emitted at the end of the translation unit (a translation unit is a source file and all of its included headers). That's why disabling them for part of the translation unit has no effect. Although the line numbers might make it appear as if the compiler is emitting these warnings in the middle of the translation unit as it's compiling the code, that's not the case.

Warning 4514 "unreferenced inline function has been removed" is emitted at the end of the translation unit by the compiler front-end (responsible for parsing C++) because only then can it determine that nothing in the translation unit references that inline function. It looks up the function's line number, but whether the warning is emitted or not depends on whether it is enabled at the end of the translation unit, not whether it was enabled while compiling that function.

因此您要么需要始终禁用它,要么不必担心它。

关于c++ - Windows SDK 7.1 编译器上的 yvals.h C4514 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10476907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com