Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio code Can';t使用MSVC构建工具使用Visual Studio代码编译文件_Visual Studio Code - Fatal编程技术网

Visual studio code Can';t使用MSVC构建工具使用Visual Studio代码编译文件

Visual studio code Can';t使用MSVC构建工具使用Visual Studio代码编译文件,visual-studio-code,Visual Studio Code,在我开始之前,我的英语还不熟练。所以请理解我糟糕的英语 我一直在努力解决这个问题 问题是使用MSVC构建工具(尤其是cl.exe)在VSC上编译是不可行的 出现错误:(致命错误C1034:iostream:未设置包含路径) 但它在VS2019的开发者命令提示符和我私下打开的cmd、PS上运行良好 尽管我在vscode中的cmd、PS上键入了命令(例如:cl helloworld.cpp),但它仍然有效 只能通过按(Ctrl+Shift+B)在VSC中生成 我花了大约3天的时间来解决这个问题 我猜

在我开始之前,我的英语还不熟练。所以请理解我糟糕的英语

我一直在努力解决这个问题

问题是使用MSVC构建工具(尤其是cl.exe)在VSC上编译是不可行的

出现错误:(致命错误C1034:iostream:未设置包含路径)

但它在VS2019的开发者命令提示符和我私下打开的cmd、PS上运行良好

尽管我在vscode中的cmd、PS上键入了命令(例如:cl helloworld.cpp),但它仍然有效

只能通过按(Ctrl+Shift+B)在VSC中生成

我花了大约3天的时间来解决这个问题

我猜导致此问题的原因是C/C++扩展无法正常工作(无法识别我在C/C++扩展中设置的includepath)或仅在VS2019的开发人员命令提示符下工作

以下是我的tasks.json:

下面是我的c_cpp_properties.json:

我尝试了所有可能的方法,比如执行vcvars64.bat、更改计算机的环境变量、删除并重新安装、修改json文件等等

我知道gcc是解决这个问题的另一种方法

但我真的很想解决这个问题

我需要你们的帮助

thx用于阅读

代码

#include <iostream>

using namespace std;

class Point
{
private:
    int xpos;
    int ypos;

public:
    Point(int x = 0, int y = 0) : xpos(x), ypos(y)
    {
    }
    friend ostream &operator<<(ostream &os, const Point &ref);

    void *operator new(size_t size)
    {
        cout << "operator new : " << size << endl;
        void *adr = new char[size];
        return adr;
    }

    void *operator new[](size_t size)
    {
        cout << "operator new[] : " << size << endl;
        void *adr = new char[size];
        return adr;
    }

    void operator delete(void *adr)
    {
        cout << "operator delete" << endl;
        delete adr;
    }

    void operator delete[](void *adr)
    {
        cout << "operator delete[]" << endl;
        delete[] adr;
    }
};

ostream &operator<<(ostream &os, const Point &ref)
{
    os << '[' << ref.xpos << ", " << ref.ypos << ']' << endl;
    return os;
}

int main(void)
{
    Point *ptr = new Point(3, 4);
    Point *arr = new Point[3];

    delete ptr;
    delete[] arr;

    return 0;
}
#包括
使用名称空间std;
类点
{
私人:
int XPO;
int ypos;
公众:
点(intx=0,inty=0):xpos(x),ypos(y)
{
}

朋友OsFrand和操作人员,你能粘贴你的代码吗?基本上是C.exe,即MS VisualStudioC/C++编译器找不到C++标题的包含目录,或者如果找到了那些目录,你的代码试图包含的文件不在这些目录中。我不知道C.exe基本上不识别。ze包含路径。我认为C/C++扩展的包含路径会起作用……嗯……谢谢你的评论。我已经附上了代码!