microsoft / vscode-cpptools

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

constructor function attribute takes arguments - but IntelliSense marks as error. #4503

Open hctim opened 4 years ago

hctim commented 4 years ago

Type: LanguageService Describe the bug

The constructor function attribute takes an optional priority field. This is incorrectly flagged as an error by IntelliSense with the following error: attribute "constructor" does not take arguments.

To Reproduce Open file with the following function declaration. Watch IntelliSense mark it as a problem with the above error.

__attribute__((constructor(1))) static void test() {}

Expected behavior No error should appear, as constructor takes an optional integer argument to specify priority.

sean-mcmanus commented 4 years ago

Thanks for reporting this. I've filed a bug on VS at https://developercommunity.visualstudio.com/content/problem/796872/cc-intellisense-in-gccclang-mode-shows-attribute-c.html .

tristan957 commented 4 years ago

I have also run into this issue. I went to upvote the linked bug above, but when I went to sign up, I couldn't unsubscribe from the VS promotional materials. Looked like there might have been an invisible check mark. Running Chrome 85. I didn't want to sign up and receive promotional material.

sean-mcmanus commented 4 years ago

@tristan957 I'm not familiar with the VS promotional materials you're describing, but you could file a complaint at https://developercommunity.visualstudio.com/ , and/or add an email filter.

tristan957 commented 4 years ago

For some reason it didn't ask me when I signed up today, so I sent an upvote to the upstream issue. I am working in a codebase close to the Linux kernel, so there is a lot of interest to me in seeing more of these attribute issues fixed up although the amount of people who would appreciate the fixes is probably close to 0. Thanks for the upstream report :)

sean-mcmanus commented 4 years ago

Using

#if __INTELLISENSE__
#pragma diag_suppress 1094
#endif

in the TU is a potential workaround (i.e. it could be added to a forcedInclude file in your configuration).

https://github.com/microsoft/vscode-cpptools/releases/tag/0.30.0-insiders5 has IntelliSense error codes added.

tristan957 commented 4 years ago

Sweet. I will be looking at that when it hits stable :). Should help tremendously in certain parts of the code.

sean-mcmanus commented 4 years ago

@tristan957 1.0.0 should be released Monday...should be identical to 0.30.0-insiders5 except for the version changes. diag_suppress should work with 0.29.0 and older as well, but you'd need to know the internal/unreported error code to use.

brvtalcake commented 1 year ago

I also went through the same issue but yeah, doing something like

#if defined(__INTELLISENSE__)
#pragma diag_suppress <error_code>
#endif

this is probably the best way to disable any false positives atm I guess