microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.54k stars 1.56k forks source link

Multi definition problem #4647

Closed h2s0109 closed 5 years ago

h2s0109 commented 5 years ago

Type: LanguageService

Describe the bug

To Reproduce

I declare the type at "Adc.h" image But there are two Adc.h files Platform_Types.h is also same. second Adc.h is not unintended file in the below figure. Maybe it looks automatically include by a tool image I would like to remove the auto-include file. How can I remove the auto-include file? I found the temporary solution like this #include "tricore\inc\Adc.h". I would like to find the more right solution

michelleangela commented 5 years ago

Have you tried setting the includes and browse path in the c_cpp_properties.json?

h2s0109 commented 5 years ago

The below code is my JSON. Can you guide what should I include?

I havent inserted below paths by myself. I cant understand why those paths is included. C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\adc.h C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\qcc\windows\platform_types.h My compiler doesn`t belong to gcc and msvc. I just use the tool editing and code. analysis

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE",
                "_TASKING_C_TRICORE_"
            ],
            "compilerPath": "C:/Program Files (x86)/TASKING/TriCore v6.2r2/ctc/bin/ctc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}
h2s0109 commented 5 years ago

I found a related issue #2601 so I have modified the below points "compilerPath": "",

  1. undefined problem solved but still, it shows an unwanted path C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\adc.h

  2. when I set "compilerPath": "C:/Program Files (x86)/TASKING/TriCore v6.2r2/ctc/bin/ctc.exe", there is a undefined message. Is it the right operation?

image

michelleangela commented 5 years ago

If the compilerPath is set, IntelliSense will try to query its related system include paths. But if it is not set, then IntelliSense will use the include paths defined under includePath. It looks like the desired header file is under the ${workspaceFolder} path which is already set to recursively include folders for includePath, so IntelliSense should only include the header files from that path. It could be adding the include from Windows kit because some other configuration setting is not getting set correctly.

The correct way, though, is to set compilerPath to "" (that is let the IntelliSense know to not query a compiler for system includes). And specific the desired include paths under includePath.

Can you share a log from running C/C++: Log Diagnostics with the following configuration? I added setting limitSymbolsToIncludedHeaders to true even though the default is true.


{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/tricore/inc"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE",
                "_TASKING_C_TRICORE_"
            ],
            "compilerPath": "",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "browse": {
                "limitSymbolsToIncludedHeaders": true
            }
        }
    ],
    "version": 4
}
michelleangela commented 5 years ago

Can you also run the command C/C++: Reset IntelliSense Database after changing the configuration?

h2s0109 commented 5 years ago

After `C/C++: Reset IntelliSense Database' problem solved. Thanks for your help