Skip to content

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

Closed as not planned

Description

@hctim

Type: LanguageService
Describe the bug

  • OS and Version: Ubuntu (private build)
  • VS Code Version: ms-vscode.cpptools
  • C/C++ Extension Version: Version 0.26.0: October 15, 2019
  • Other extensions you installed (and if the issue persists after disabling them): N/A
  • A clear and concise description of what the bug is.

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.

Activity

  1. sean-mcmanus commented on Oct 28, 2019

    @sean-mcmanus
    Contributor
  2. tristan957 commented on Sep 9, 2020

    @tristan957

    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.

  3. sean-mcmanus commented on Sep 9, 2020

    @sean-mcmanus
    Contributor

    Tristan Partin (@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.

  4. tristan957 commented on Sep 10, 2020

    @tristan957

    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 :)

  5. sean-mcmanus commented on Sep 11, 2020

    @sean-mcmanus
    Contributor

    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.

  6. tristan957 commented on Sep 11, 2020

    @tristan957

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

  7. sean-mcmanus commented on Sep 11, 2020

    @sean-mcmanus
    Contributor

    Tristan Partin (@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.

  8. brvtalcake commented on Feb 7, 2023

    @brvtalcake

    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

  9. bobbrow commented on Dec 18, 2024

    @bobbrow
    Contributor

    The issue we opened against Visual Studio was closed as "lower priority" so unfortunately that means we won't likely be getting a fix for it in VS Code either.

  10. locked and limited conversation to collaborators on Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions