Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. __attribute__((???)) ignored
QtWS25 Last Chance

__attribute__((???)) ignored

Scheduled Pinned Locked Moved Solved C++ Gurus
5 Posts 3 Posters 544 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Kent-DorfmanK Offline
    Kent-DorfmanK Offline
    Kent-Dorfman
    wrote on last edited by
    #1

    whiskey tango, guys

    I've always tried to avoid coding where I need to play with compiler directives but I've got some stuff where I need to mark functions as "unused". The offending function is a private static helper function in a compilation unit. It's not activated until I get other parts of the project completed and the warnings annoy my sensibilities.

    Anyway, gnu/c++ is "suppose" to support

    static void helper() __attribute__((unused));
    

    but regardless of what I try it continues to be flagged as an "unused function" warnign with -Wall during compilation.

    I also tried

    static void helper()  [[unused]];
    

    with equally undesirable results.

    my compilation options show "under eclipse IDE" as:

    g++ -std=c++17 -I"/home/me/eclipse-2403/farm" -O0 -g3 -Wall -c -fmessage-length=0
    

    What gives, with gnu not accepting function attributes?

    jeremy_kJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Which version of g++ are you using ?
      With which distribution ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      Kent-DorfmanK 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Which version of g++ are you using ?
        With which distribution ?

        Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #3

        @SGaist

        gcc/g++ 10.2
        on Debian 10

        1 Reply Last reply
        0
        • Kent-DorfmanK Kent-Dorfman

          whiskey tango, guys

          I've always tried to avoid coding where I need to play with compiler directives but I've got some stuff where I need to mark functions as "unused". The offending function is a private static helper function in a compilation unit. It's not activated until I get other parts of the project completed and the warnings annoy my sensibilities.

          Anyway, gnu/c++ is "suppose" to support

          static void helper() __attribute__((unused));
          

          but regardless of what I try it continues to be flagged as an "unused function" warnign with -Wall during compilation.

          I also tried

          static void helper()  [[unused]];
          

          with equally undesirable results.

          my compilation options show "under eclipse IDE" as:

          g++ -std=c++17 -I"/home/me/eclipse-2403/farm" -O0 -g3 -Wall -c -fmessage-length=0
          

          What gives, with gnu not accepting function attributes?

          jeremy_kJ Offline
          jeremy_kJ Offline
          jeremy_k
          wrote on last edited by
          #4

          @Kent-Dorfman said in __attribute__((???)) ignored:

          static void helper()  [[unused]];
          

          Perhaps [[maybe_unused]]?

          The function example also places the attribute before the function signature.

          Asking a question about code? http://eel.is/iso-c++/testcase/

          Kent-DorfmanK 1 Reply Last reply
          2
          • jeremy_kJ jeremy_k

            @Kent-Dorfman said in __attribute__((???)) ignored:

            static void helper()  [[unused]];
            

            Perhaps [[maybe_unused]]?

            The function example also places the attribute before the function signature.

            Kent-DorfmanK Offline
            Kent-DorfmanK Offline
            Kent-Dorfman
            wrote on last edited by Kent-Dorfman
            #5

            @jeremy_k

            that is weird. some examples place the directive after the declaration and others before like it shouldn't matter...but you are right. It did make a different. Placing it before the declation cause the warning to be igrnored.

            looks like gcc documention is wrong...go figure. LOL

            wrong in TWO PLACES...First, they say "unused" is a valid attribute, and second, internal examples sometimes place the attribute after the decl.

            Hmmm.

            1 Reply Last reply
            0
            • Kent-DorfmanK Kent-Dorfman has marked this topic as solved on

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved