简体   繁体   中英

How to use Include paths for IntelliSense in VS code with C++ compiler

Visual Studio Code has the possibility to use an external compiler to build and debug the code. It also has an IntelliSence module to highlight the code syntaxis and has a variable includePath to let the IntelliSence know where to find header files. But is there any possibility to supply the compiler with these include paths? Or I must support also a make file with the same set of directories?

If you click a highlighted include that it can't find right away, a lightbulb icon should show up. Click it and Edit the IncludePath setting. This will create a .vscode/c_cpp_properties.json in your project folder.

Naturally, you can create the file yourself as well. Here's a quick one from my laptop:

{
    "configurations": [
        {
            "name": "Mac",
            "defines": [],
            "macFrameworkPath": [
                "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
            ],
            "compilerPath": "/usr/bin/clang",
            "includePath": [
                "${default}",
                "${workspaceFolder}/include"
            ]
        }
    ],
    "version": 4
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM