【发布时间】:2023-01-03 23:27:03
【问题描述】:
我在 Visual Studio 2022 中编写了一些代码,然后将其复制到 VS Code,以便将其编译为节点模块。我在 Visual Studio 中没有收到任何错误,但在 VS Code 中收到以下错误:
namespace "std" has no member "format" C/C++(135)。
代码编译没有错误并且工作正常,但我的工作区被错误消息污染了。
如果有人能指出这些消息的原因以及如何抑制它们,我将不胜感激。
下面是详细的编译信息:
> node-gyp rebuild -j max && set_modules && tsc && node ./final/index.js
gyp info it worked if it ends with ok
gyp info using node-gyp@9.0.0
gyp info using node@16.14.0 | win32 | x64
gyp info find Python using Python version 3.10.2 found at "C:\Python310\python.exe"
gyp info find VS using VS2022 (17.2.32519.379) found at:
gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Community"
【问题讨论】:
-
这看起来像一个错误,而不是警告。你确定它真的编译了吗?如果你从你的文件夹中删除可执行文件,它会在你编译后再次生成吗?
-
gcc还没有实现std::format。您可以使用第三方库来做很多相同的事情fmt。 -
@Yksisarvinen:是的,它确实编译。我现在正在处理它,做出反映在模块中的更改等。
-
大多数 IDE 使用不同的“编译器”来进行语法高亮显示,就像它们用于实际编译一样。差异几乎可以肯定归结于此。
std::format是 C++20 及更高版本。 -
看起来您收到的是智能感知错误,而不是编译器错误。您希望能够区分两者,并在提问时告诉我们您得到了什么。