VS Code / MinGW intellisence不适用于C ++

时间:2018-03-10 14:09:12

标签: c++ visual-studio-code mingw intellisense template-classes

我的头文件中有一个模板类,我还需要一个.hpp文件来实现函数。

问题出在VS Code或MinGW上。

在VS代码中:

  • 我安装了Microsoft的C / C ++扩展
  • 这是我的c_cpp_properties.json文件:

        {
        "files.associations": {
        "iostream": "cpp",
        "ostream": "cpp",
        "*.tcc": "cpp",
        "cctype": "cpp",
        "clocale": "cpp",
        "cstdint": "cpp",
        "cstdio": "cpp",
        "cstdlib": "cpp",
        "cwchar": "cpp",
        "cwctype": "cpp",
        "exception": "cpp",
        "initializer_list": "cpp",
        "iosfwd": "cpp",
        "istream": "cpp",
        "limits": "cpp",
        "new": "cpp",
        "stdexcept": "cpp",
        "streambuf": "cpp",
        "system_error": "cpp",
        "type_traits": "cpp",
        "typeinfo": "cpp",
        "fstream": "cpp"
        },
        "C_Cpp.intelliSenseEngineFallback": "Enabled"
      }
    

    }

  • 这是我的settings.json(如果需要):

    gulp.task('watch', function() {
        gulp.watch('**/*.html', gulp.series('htmlcomb'));
        gulp.watch('css/**/*.scss', gulp.series('csscomb'));
        gulp.watch('css/**/*.scss', gulp.series('cssmin'));        
        gulp.watch('js/**/*.js', gulp.series('jsmin'));
    });
    

我已将文件目录包含在Windows的环境变量设置中。

当我打开问题窗口时,主要问题是在VS Code中,intellisense对.hpp文件不起作用。这件事发生在我和另一个我知道的事情上。有人知道修复吗?

我相信这就是所需要的一切。 (我已经包含了VS Code与编译器对话的所有内容)

2 个答案:

答案 0 :(得分:0)

尝试替换

"C_Cpp.intelliSenseEngineFallback": "Enabled"

以下线

"C_Cpp.intelliSenseEngine": "Default"

然后重启VS Code。

答案 1 :(得分:0)

删除{"name": "Win32"{..}}部分并将以下部分添加到"configurations"

{
            "name": "MinGW",
            "intelliSenseMode": "clang-x64",
            "compilerPath": "C:/MinGW/bin/gcc.exe",
            "includePath": [
                "${workspaceRoot}",
            ],
            "defines": [
                "_DEBUG"
            ],
            "browse": {
                "path": [
                    "C:/MinGW/lib/gcc/mingw32/6.3.0/include",
                    "C:/MinGW/lib/gcc/mingw32/6.3.0/include-fixed",
                    "C:/MinGW/include/*"
                    "${workspaceRoot}",
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }

在MinGW的Windows上它适用于我。

参考:https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/MinGW.md