CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    __attribute__ ??

    I'm building a project here which used to build fine with VS2008. There's one function which looks like this:-

    Code:
    __attribute__((constructor))
    static void init_weak_jack(void)
    {
        // rest of function
    }
    but VS2019 doesn't understand the __attribute__ keyword. I can't see it defined in the project's header files so I'm assuming it used to be a VS2008 keyword. Is it something that's maybe deprecated now?
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: __attribute__ ??

    Hi John, as far as I could find here:
    __attribute__ is not a macro, it is a GCC specific extension that needs to be replaced with appropriate equivalent Visual C++ has. Its equivalent is usually __declspec
    Also have a look at
    https://social.msdn.microsoft.com/Fo...orum=vcgeneral
    Victor Nijegorodov

  3. #3
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: __attribute__ ??

    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #4
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: __attribute__ ??

    Thanks guys. For the moment I've just commented the line out - and AFAICT it isn't causing any problems
    "A problem well stated is a problem half solved.” - Charles F. Kettering

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured