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

__declspec attribute is not recognised with -fdeclspec #12282

Open
kodenamekrak opened this issue May 5, 2024 · 2 comments
Open

__declspec attribute is not recognised with -fdeclspec #12282

kodenamekrak opened this issue May 5, 2024 · 2 comments
Assignees
Labels
bug Feature: Configuration An issue related to configuring the extension or IntelliSense Language Service verified Bug has been reproduced

Comments

@kodenamekrak
Copy link

kodenamekrak commented May 5, 2024

Environment

  • OS and Version: Ubuntu 23.10
  • VS Code Version: 1.89.0 b58957e67ee1e712cebf466b995adf4c5307b2bd
  • C/C++ Extension Version: v1.19.9
  • If using SSH remote, specify OS of remote machine:

Bug Summary and Steps to Reproduce

Bug Summary:

When using clang the __declspec attribute is not recognised in vscode when -fdeclspec is present in the compiler arguments even though the code compiles succesfully.

Steps to reproduce:

The following code compiles perfectly fine with clang++ main.cpp -fdeclspec

struct Foo {
    int get_number() { return 5; }
    __declspec(property(get=get_number)) int number;
};

int main(int argc, char** argv) {
    return 0;
}

vscode is unable to recognise __declspec when -fdeclspec and shows the following errors:

explicit type is missing ('int' assumed) [Ln 3, Col 5]
identifier "property" is undefined [Ln 3, Col 16]
expected a ')' [Ln 3, Col 28]
expected a ';' [Ln 3, Col 42]

Expected behavior:

__declspec is seen as valid code like when -fms-extensions is present

Configuration and Logs

{
    "configurations": [
        {
            "name": "linux",
            "compilerPath": "/usr/bin/clang",
            "intelliSenseMode": "linux-clang-x64",
            "configurationProvider": "ms-vscode.cpptools",
            "compilerArgs": [
                "-fdeclspec"
            ]
        }
    ],
    "version": 4
}




loggingLevel: Debug
loggingLevel has changed to: Debug
LSP: (invoked) cpptools/didChangeCppProperties (id: 16)
LSP: Sending response (id: 16)
LSP: (received) cpptools/fileCreated: file:///home/kodenamekrak/Documents/C%2B%2B/test/.vscode/settings.json
LSP: (invoked) cpptools/fileCreated: file:///home/kodenamekrak/Documents/C%2B%2B/test/.vscode/settings.json
LSP: (received) cpptools/fileCreated: file:///home/kodenamekrak/Documents/C%2B%2B/test/.vscode/settings.json
LSP: (invoked) cpptools/fileCreated: file:///home/kodenamekrak/Documents/C%2B%2B/test/.vscode/settings.json
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
Intellisense update pending for: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp
LSP: (received) cpptools/didChangeActiveEditor: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp
LSP: (invoked) cpptools/didChangeActiveEditor: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp
LSP: (received) cpptools/getCodeActions: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 17)
LSP: (invoked) cpptools/getCodeActions: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 17)
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: Sending response (id: 17)
LSP: (invoked) cpptools/didChangeTextEditorSelection
IntelliSense update scheduled and TU acquisition started for: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp
Update IntelliSense time (sec): 0.002
LSP: (received) cpptools/getFoldingRanges: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 18)
LSP: (invoked) cpptools/getFoldingRanges: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 18)
LSP: Sending response (id: 18)
LSP: (received) cpptools/getCodeActions: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 19)
LSP: (invoked) cpptools/getCodeActions: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 19)
LSP: Sending response (id: 19)
LSP: (received) cpptools/getDocumentSymbols: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 20)
LSP: (invoked) cpptools/getDocumentSymbols: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 20)
LSP: Sending response (id: 20)
LSP: (received) textDocument/hover: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 21)
LSP: (invoked) textDocument/hover: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 21)
LSP: Sending response (id: 21)
LSP: (received) cpptools/getCodeActions: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 22)
LSP: (invoked) cpptools/getCodeActions: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 22)
LSP: Sending response (id: 22)
LSP: (received) textDocument/hover: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 23)
LSP: (invoked) textDocument/hover: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 23)
LSP: Sending response (id: 23)
LSP: (received) textDocument/hover: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 24)
LSP: (invoked) textDocument/hover: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 24)
LSP: Sending response (id: 24)
LSP: (received) textDocument/hover: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 25)
LSP: (invoked) textDocument/hover: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 25)
LSP: Sending response (id: 25)
LSP: (received) cpptools/getCodeActions: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 26)
LSP: (invoked) cpptools/getCodeActions: file:///home/kodenamekrak/Documents/C%2B%2B/test/main.cpp (id: 26)
LSP: Sending response (id: 26)






-------- Diagnostics - 5/5/2024, 10:19:22 PM
Version: 1.19.9
Current Configuration:
{
    "name": "linux",
    "compilerPath": "/usr/bin/clang",
    "intelliSenseMode": "linux-clang-x64",
    "configurationProvider": "ms-vscode.cpptools",
    "compilerArgs": [
        "-fdeclspec"
    ],
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "intelliSenseModeIsExplicit": true,
    "compilerPathInCppPropertiesJson": "/usr/bin/clang",
    "configurationProviderInCppPropertiesJson": "ms-vscode.cpptools",
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
cpptools version (native): 1.19.9.0
Translation Unit Mappings:
[ /home/kodenamekrak/Documents/C++/test/main.cpp - source TU]:
Translation Unit Configurations:
[ /home/kodenamekrak/Documents/C++/test/main.cpp ]:
    Process ID: 163784
    Memory Usage: 11 MB
    Compiler Path: /usr/bin/clang
    Includes:
        /usr/include/c++/13
        /usr/include/x86_64-linux-gnu/c++/13
        /usr/include/c++/13/backward
        /usr/lib/llvm-16/lib/clang/16/include
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
    Standard Version: c++17
    IntelliSense Mode: linux-clang-x64
    Other Flags:
        --clang
        --clang_version=160006
Total Memory Usage: 11 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 11127

Other Extensions

This issue still occurs even when c/c++ is the only enabled extension

Additional context

No response

@kodenamekrak kodenamekrak changed the title __declspec incorrectly not recognised when -fms-extensions is not present __declspec attribute is not recognised with -fdeclspec May 5, 2024
@sean-mcmanus sean-mcmanus self-assigned this May 7, 2024
@sean-mcmanus sean-mcmanus added bug Language Service Feature: Configuration An issue related to configuring the extension or IntelliSense verified Bug has been reproduced labels May 7, 2024
@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented May 7, 2024

@kodenamekrak Our parser only currently recognizes -fms_extensions -- would it be acceptable for us to enable all ms extensions when -fdeclspec is encountered or does your scenario only compile with that one specific change and not the other ms extensions?

@kodenamekrak
Copy link
Author

Enabling ms extensions would be a fine solution since its better that nothing, as for other ms extensions i cannot say as i have mever used any others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Feature: Configuration An issue related to configuring the extension or IntelliSense Language Service verified Bug has been reproduced
Projects
None yet
Development

No branches or pull requests

2 participants