MSYS2和Visual Studio 2019-将GCC与Intellisense一起使用

时间:2019-04-14 22:00:33

标签: visual-studio gcc msys2 visual-studio-2019

在VS2019中使用Intellisense和新的“打开项目”选项时,我遇到了麻烦。

目标是将VS用于智能感知,并使用与Linux兼容的标准发行的makefile,而无需求助于CMAKE或其他任何东西。

但是,我得到的东西是,“命名空间'std'没有成员'cout”-很基本的东西;因此,Intellisense不会读取std名称空间所需的所有内容。

main.cpp:

#include "circle.h"
#include <iostream>

 int main(){
    Circle new_circle;
    new_circle.setRadius(3.0);
    std::cout << new_circle.getArea() << std::endl;
 }

circle.h:

class Circle
{
    private:
        double radius;
    public:
        void setRadius(double r); 
        double getArea();
};

CppProperties.json:

{
  "configurations": [
    {
      "inheritEnvironments": [
        "mingw64"
      ],
      "name": "Mingwx64-Debug",
      "includePath": [
        "C:\\msys64\\mingw64\\x86_64-w64-mingw32\\include",
        "C:\\msys64\\mingw64\\include\\c++\\8.3.0\\x86_64-w64-mingw32\\bits",
        "C:\\msys64\\mingw64\\include\\c++\\8.3.0",
        "${env.INCLUDE}",
        "${workspaceRoot}\\**"
      ],
      "defines": [
        "__GNUC__"

      ],
      "intelliSenseMode": "windows-clang-x64"
    }
  ],
  "environments": [
    {
      "INCLUDE": "\"project/lib/include;${env.MINGW_PREFIX}/mingw/include; ${env.MINGW_PREFIX}/include/c++/8.3.0/;${env.MINGW_PREFIX}/include/c++/8.3.0/x86_64-w64-mingw32/bits ; ${env.MINGW_PREFIX}/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/include; ; ${env.MINGW_PREFIX}/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../include; ${env.MINGW_PREFIX}/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/include-fixed; ${env.MINGW_PREFIX}/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w6",
      "MINGW_CHOST ": "x86_64-w64-mingw32",
      "MINGW_PACKAGE_PREFIX": "mingw-w64-x86_64",
      "MINGW_PREFIX": "C:/msys64/mingw64",
      "MSYSTEM": "MINGW64",
      "MSYSTEM_CARCH": "x64_64",
      "MSYSTEM_PREFIX": "${env.MINGW_PREFIX}",
      "PATH": "${env.MINGW_PREFIX}/bin;${env.MINGW_PREFIX}/../usr/local/bin;${env.MINGW_PREFIX}/../usr/bin;${env.PATH};",
      "SHELL": "${env.MINGW_PREFIX}/../usr/bin/bash",
      "TEMP": "${env.MINGW_PREFIX}/../tmp",
      "TMP": "${env.TEMP}"
    }
  ]
}

Makefile:

.RECIPEPREFIX = >

all: circle.cpp main.cpp
> g++ main.cpp circle.cpp -o main

请帮助,这让我发疯了!

0 个答案:

没有答案