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

__attribute__((???)) ignored

Scheduled Pinned Locked Moved Solved C++ Gurus
5 Posts 3 Posters 550 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.
  • K Offline
    K Offline
    Kent-Dorfman
    wrote on 4 Jun 2024, 17:59 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?

    J 1 Reply Last reply 4 Jun 2024, 20:44
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 4 Jun 2024, 19:26 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

      K 1 Reply Last reply 4 Jun 2024, 20:33
      0
      • S SGaist
        4 Jun 2024, 19:26

        Hi,

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

        K Offline
        K Offline
        Kent-Dorfman
        wrote on 4 Jun 2024, 20:33 last edited by
        #3

        @SGaist

        gcc/g++ 10.2
        on Debian 10

        1 Reply Last reply
        0
        • K Kent-Dorfman
          4 Jun 2024, 17:59

          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?

          J Offline
          J Offline
          jeremy_k
          wrote on 4 Jun 2024, 20:44 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/

          K 1 Reply Last reply 4 Jun 2024, 21:03
          2
          • J jeremy_k
            4 Jun 2024, 20:44

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

            static void helper()  [[unused]];
            

            Perhaps [[maybe_unused]]?

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

            K Offline
            K Offline
            Kent-Dorfman
            wrote on 4 Jun 2024, 21:03 last edited by Kent-Dorfman 6 Apr 2024, 21:05
            #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
            • K Kent-Dorfman has marked this topic as solved on 4 Jun 2024, 21:05

            1/5

            4 Jun 2024, 17:59

            • Login

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