microsoft / vscode-cpptools

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

Undefined functions do not report errors #12405

Closed xren5321 closed 4 weeks ago

xren5321 commented 1 month ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: image image image

Configuration and Logs

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "STM32F103",
            "includePath": [
                "E:/embedded/vscode/test1/Core/Inc",
                "E:/embedded/vscode/test1/Drivers/CMSIS/Device/ST/STM32F1xx/Include",
                "E:/embedded/vscode/test1/Drivers/CMSIS/Include",
                "E:/embedded/vscode/test1/Drivers/STM32F1xx_HAL_Driver/Inc",
                "E:/embedded/vscode/test1/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy"
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": false,
                "path": [
                    "E:/embedded/vscode/test1/Drivers/STM32F1xx_HAL_Driver/Src",
                    "E:/embedded/vscode/test1/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates"
                ]
            },
            "cStandard": "c17",
            "cppStandard": "gnu++14",
            "defines": [
                "STM32F103xB",
                "USE_HAL_DRIVER",
                ""
            ],
            "compilerPath": "E:/software/VScode/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc.exe",
            "compilerArgs": [
                "-mthumb",
                "-mcpu=cortex-m3",
                ""
            ],
            "intelliSenseMode": "${default}"
        }
    ],
    "version": 4
}

settings.json 
{
    "files.associations": {
        "main.h": "c",
        "stm32f1xx_hal.h": "c",
        "stm32f1xx_hal_def.h": "c",
        "stddef.h": "c",
        "stm32f1xx.h": "c"
    }
}

Other Extensions

No response

Additional context

This is a cubemx generated makefile format code, I write a random function in the main C/CPP does not give hints

browntarik commented 4 weeks ago

Could you provide the codebase you are using to reproduce this error?

browntarik commented 4 weeks ago

After further investigation, it looks like you are facing an existing issue due to by-design behavior from c-compilers. C-compilers process implicit functions as warnings and not errors. Thus, IntelliSense will not squiggle an undefined function with an error squiggle before compilation (see below).

image

After compilation, you should see a warning flag generated using the -Wimplicit-function-declaration in the c compiler.

image

More information can be found on another issue addressing this here: https://github.com/microsoft/vscode-cpptools/issues/828

This issue will now be closed as a duplicate. Please let us know if you have further concerns.

xren5321 commented 3 weeks ago

thank you. So is Clang-Tidy supported now?

sean-mcmanus commented 3 weeks ago

@xren5321 It is, via the Run Code Analysis commands (and C_Cpp.codeAnalysis.* settings).