microsoft / vscode-cpptools

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

Undefined Variables/Classes with content-aware Intellisense #3649

Closed joelvonrotz closed 5 years ago

joelvonrotz commented 5 years ago

Type: LanguageService

Describe the bug

Classes and various other definitions have the "identifier XYZ is undefined"-error in the normal Intellisense-mode, despite still being content-aware and findable with "Go to Defintion". Tag-Parser works without any problems. A couple of versions ago (I don't know which one it was) the Intellisense seemed to work, the only errors that occured where missing files.

The code is compile-able with Keil uVision 5 and the defines from uVision have been included in the C/C++ Properties.

To Reproduce

  1. Export project from mbed-Online compiler as a zipped-Project
  2. Extract project
  3. Open Visual Studio Code in this folder
  4. Add include paths

Content of c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/",
                "C:/Keil_v520/ARM/ARMCC/include/**",
                "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Include",
                "${workspaceFolder}/Libraries/mbed",
                "${workspaceFolder}/Libraries/mbed/TARGET_LPC1768/TOOLCHAIN_ARM_STD",
                "${workspaceFolder}/Libraries/mbed/platform",
                "${workspaceFolder}/Libraries/mbed/hal",
                "${workspaceFolder}/Libraries/mbed/drivers",
                "${workspaceFolder}/Sources/Drivers/inc"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE",

                "DEVICE_ANALOGIN=1",
                "DEVICE_ANALOGOUT=1",
                "DEVICE_EMAC=1",
                "DEVICE_RTC=1 ",
                "DEVICE_SLEEP=1",
                "DEVICE_SEMIHOST=1",
                "DEVICE_PWMOUT=1",
                "DEVICE_CAN=1",
                "DEVICE_PORTOUT=1",
                "DEVICE_FLASH=1",
                "DEVICE_STDIO_MESSAGES=1",
                "DEVICE_ETHERNET=1",
                "DEVICE_USTICKER=1",
                "DEVICE_I2C=1",
                "DEVICE_PORTIN=1",
                "DEVICE_INTERRUPTIN=1",
                "DEVICE_SPI=1",
                "DEVICE_SPISLAVE=1",
                "DEVICE_SERIAL_FC=1",
                "DEVICE_LOCALFILESYSTEM=1",
                "DEVICE_SERIAL=1",
                "DEVICE_I2CSLAVE=1",
                "DEVICE_PORTINOUT=1__CORTEX_M3",
                "DEVICE_DEBUG_AWARENESS=1",

                "TARGET_LPC1768",
                "TARGET_RELEASE",
                "TARGET_M3",
                "TARGET_LIKE_CORTEX_M3",
                "TARGET_CORTEX_M",
                "TARGET_NXP_EMAC",
                "TARGET_LPCTarget",
                "TARGET_LIKE_MBED",
                "TARGET_LPC176X",
                "TARGET_CORTEX",
                "TARGET_NXP",
                "TARGET_MBED_LPC1768",

                "TOOLCHAIN_ARM",
                "TOOLCHAIN_ARM_STD",

                "ARM_MATH_CM3",

                "MBED_ROM_SIZE=0x80000",
                "MBED_BUILD_TIMESTAMP=1548252170.57",
                "MBED_ROM_START=0x0",

                "__ASSERT_MSG",
                "__MBED__=1",
                "__CMSIS_RTOS",
                "__MBED_CMSIS_RTOS_CM"
            ],
            "compilerPath": "",
            "cStandard": "c99",
            "cppStandard": "c++11",
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 4
}

Expected behavior The code is content aware without any errors.

Screenshots image Image shows a CAN-object called "can". The CAN-class gives of the Undefined-error, while calling functions from the object "can" is correctly content-aware (the functions are CAN-functions only).

image Modified settings

sean-mcmanus commented 5 years ago

Previously, the intelliSenseEngineFallback was set to Default instead of Disabled, so if a header was missing it would not show any squiggles. The completion comments are probably coming from the tag parser. Can you go to the definition of CAN and see why IntelliSense isn't compiling the definition? I would guess a define is not set. Also, it seems like you may want to set the intelliSenseMode to gcc-x64, unless you're compiling with cl.exe.

joelvonrotz commented 5 years ago

Previously, the intelliSenseEngineFallback was set to Default instead of Disabled, so if a header was missing it would not show any squiggles. The completion comments are probably coming from the tag parser. Can you go to the definition of CAN and see why IntelliSense isn't compiling the definition? I would guess a define is not set. Also, it seems like you may want to set the intelliSenseMode to gcc-x64, unless you're compiling with cl.exe.

Hi Sean I was able to fix it. The whole mbed library is huge and it seems that adding one include path to a completely different compiler fixed the problem for now.

joelvonrotz commented 5 years ago

So it's my bad.