Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goto definition not working if <attr> is right after <declaration> #13129

Open
TheBrugne opened this issue Jan 8, 2025 · 5 comments
Open

goto definition not working if <attr> is right after <declaration> #13129

TheBrugne opened this issue Jan 8, 2025 · 5 comments
Assignees
Labels
Language Service more info needed The issue report is not actionable in its current state

Comments

@TheBrugne
Copy link

TheBrugne commented Jan 8, 2025

Environment

  • OS and Version: windows 10 build 19045
  • VS Code Version: 1.96.2
  • C/C++ Extension Version: 1.22.11
  • If using SSH remote, specify OS of remote machine:

Bug Summary and Steps to Reproduce

c/c++ intellisense: goto definition is not working on functions defined in .c that have attributes right after the function prototype in the header file. It goes to the declaration instead.

Example:

void Fun_A(void)  __attribute__((always_inline));  --> declared in fun_a.h
void Fun_A(void)  --> defined in fun_a.c
{
    ....
}


main()
{
  Fun_A();   --> goto definition is sending to the declaration
}

If I move the __attribute__((always_inline)) on the left of the function prototype, everything works fine, but I heard that starting from c23, the new standard is to place attributes right after the function prototype.

With older version of intellisense (such as the 1.0.0 of 4years ago) the behavior is good.

Am I missing something?

Configuration and Logs

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "windowsSdkVersion": "10.0.19041.0",
            "cStandard": "c23",
            "cppStandard": "c++17",
            "intelliSenseMode": "${default}",
            "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe"
        }
    ],
    "version": 4
}

Other Extensions

No response

Additional context

No response

@Colengms
Copy link
Contributor

I suspect this is a dupe of #10696

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Jan 11, 2025

@TheBrugne How are you getting that code to compile? With the cl.exe compiler? What args? Is IntellliSense giving any errors?

I do not repro the bug when using gcc, in which case there are no IntelliSense errors and it compiles.

@sean-mcmanus sean-mcmanus self-assigned this Jan 11, 2025
@sean-mcmanus sean-mcmanus added Language Service more info needed The issue report is not actionable in its current state labels Jan 11, 2025
@TheBrugne
Copy link
Author

@TheBrugne How are you getting that code to compile? With the cl.exe compiler? What args? Is IntellliSense giving any errors?

I do not repro the bug when using gcc, in which case there are no IntelliSense errors and it compiles.

Hello Sean,
I'm using vscode just as text editor for my project.

The project runs on a cortex m23 custom device, compiled with armclang 6.16 and the compiler is parsing correctly the attribute placed on the right of function. Of course I cannot select armclang as compiler in vscode, so this is my setup:

{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/"
"${CMSIS_PATH}/CMSIS/Include/
",
"${KEIL_COMPILER_PATH}/ARMCLANG/include/**",
],
"windowsSdkVersion": "10.0.19041.0",
"cStandard": "c23",
"cppStandard": "c++17",
"intelliSenseMode": "${default}",
"compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe"
}
],
"version": 4
}

Thank for your support.
Regards,
Andrea

@sean-mcmanus
Copy link
Contributor

@TheBrugne Are you not able to set your compilerPath to the arm clang compiler? Does it not support the query flags? If that's the case, then you should set the compilerPath to "" and not to the cl.exe, which will cause it to compile in a different compiler mode which doesn't accept the gcc attributes. And set the intelliSenseMode to "windows-clang-arm" or "windows-clang-arm64".

@TheBrugne
Copy link
Author

@TheBrugne Are you not able to set your compilerPath to the arm clang compiler? Does it not support the query flags? If that's the case, then you should set the compilerPath to "" and not to the cl.exe, which will cause it to compile in a different compiler mode which doesn't accept the gcc attributes. And set the intelliSenseMode to "windows-clang-arm" or "windows-clang-arm64".

Many Thank you Sean, you solution is working!
You can close the the issue :)

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Language Service more info needed The issue report is not actionable in its current state
Projects
Status: No status
Development

No branches or pull requests

3 participants