mitaki28 / vscode-clang

Completion and Diagnostic for C/C++/Objective-C using Clang
MIT License
128 stars 24 forks source link

Can't find include file when have set c_cpp_properties.json #50

Open suemi994 opened 7 years ago

suemi994 commented 7 years ago

System : OSX 10.12.3 vscode version: 1.11.1 clang adapter version: 0.2.2

Clang command adapter can't find the file included and path has been added in c_cpp_properties.json

the configuration is

"configurations": [
        {
            "name": "Mac",
            "includePath": [
                "/usr/include",
                "/usr/local/include",
                "/Library/Developer/CommandLineTools/usr/include/c++/v1",
                "${workspaceRoot}/src"
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        },
        {
            "name": "Linux",
            "includePath": [
                "/usr/include",
                "/usr/local/include"
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        },
        {
            "name": "Win32",
            "includePath": [
                "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*"
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }
    ]

And it gives the error

file: 'file:///Users/suemi/Workspace/SimpleRpc/src/rpc/net/rpc_message_handler.cc'
severity: '错误'
message: ''rpc/net/rpc_message_handler.h' file not found'
at: '5,10'
source: ''
tashia commented 7 years ago

I am also seeing an issue in the latest vs code. The autocomplete for header file is not working. Not sure if this is related. When I type #include <v>, what I expect it would give some header file suggestions like vector. It used to be working. Don't why it suddenly is not working

Triangle345 commented 7 years ago

i'm also seeing the same issue. When including a header inside a header file (eg. #include ), I get a red squiggle with "file not found"

s-imphead commented 7 years ago

The combination of MS cpptools 0.11.0 and cmake tools on Linux doesn't work so well either: the configuration button (lower right) disappears. I guess that's OK since the configuration choice is up to cmake. But, it turns out that cpptools now looks for include files under the Mac section of c_cpp_properties.js --- even as Cmake declares

The system is: Linux - 4.4.0-72-generic - x86_64

Grizzbear commented 7 years ago

Try add clang configuration in settings.json. The settings looks like: "clang.cflags": ["-fsyntax-only", "-Ix:/xxx/include1", "-Ix:/xxx/include2"] Note there shouldn't be any white space between -I and your include path, or the extension would throw include file not found error.

abmantis commented 6 years ago

Are we supposed to set the include paths trough clang.cflags, trough the c_cpp_properties.json, or both?

Misairu-G commented 6 years ago

@abmantis Why do you want to use both extension at the same time? clang extension already provides auto-completion and diagnostic. Setting clang flags and disable M$ c/c++ extension and you'll be fine.

igormcoelho commented 5 years ago

I just discovered I was having issues with this extension (I thought it was another one, vscode-cpptools), where my includes are being indicated as File not found, even if they existed: https://github.com/Microsoft/vscode-cpptools/issues/2521

A simple bugged scenario is here: https://github.com/Microsoft/vscode-cpptools/issues/2521#issuecomment-488548487 I can reproduce it later if someone is interested in diagnosing the causes of the issue, but it is exactly the same reproduced here... I'll try to test the indicated flags.