【问题标题】:is Undefined Errors in VS Code MinGW Vs. Win32是 VS Code MinGW Vs 中的未定义错误。 Win32
【发布时间】:2019-12-03 05:27:50
【问题描述】:

我的 VSCode 遇到问题。

当我使用 MinGW 时,它会显示 identifier ... is Undefined 的错误,这不会影响代码的执行,
但是当我切换到 Win32 时,所有这些错误都消失了。即使我包含了所需的库,也会发生这种情况。我想知道是否有人可以帮我解决问题是什么,我该如何解决。

这是我的标题:

#include <iostream>
#include <vector>
#include <tuple>
#include <fstream>
#include <algorithm>
#include <windows.h>
#include <ctime>

例如,如果我编写一个简单的代码来处理这样的时间:

int main()
{

    time_t now = time(0);
    cout<<ctime(&now);

    return 0;
}

只有在我使用 MinGW 时才会显示这样的错误

identifier "make_tuple" is undefined
identifier "get" is undefined
identifier "time" is undefined
identifier "localtime" is undefined
identifier "asctime" is undefined
identifier "ctime" is undefined

【问题讨论】:

  • 请不要发布代码或消息的图片。他们对搜索不友好。请以文本形式发布代码和消息。
  • 现在可以了吗?! @RSahu
  • 这样更好。如果能发minimal reproducible example就更好了。

标签: c++ visual-studio-code mingw


【解决方案1】:

确保为这些函数使用 std:: 前缀。

std::make_tuple等代替make_tuple

【讨论】:

  • 我一开始用using namespace std;够了吗? @R萨胡
猜你喜欢
  • 2013-06-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-19
  • 2020-02-11
  • 2018-07-21
  • 1970-01-01
  • 2020-10-20
相关资源
最近更新 更多