Help with using _attribute_ ((unused))

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dissectcode
    New Member
    • Jul 2008
    • 66

    Help with using _attribute_ ((unused))

    I am trying to learn how to use the attribute unused so I created a little test program. Can you please tell me what is wrong? I get syntax errors "before attribute" and "before (" (sometimes).

    Code:
    #include <stdio.h>
    
    #define UNUSED _attribute_ ((unused))
    
    void testUnused(int a UNUSED, int b);
    
    int main()
    {
      //testUnused(2, 5);  //i tried commenting this out, but still get syntax error
      printf("hello\n");
    }
    
    void testUnused(int a UNUSED, int b)
    {
      printf("%d", b);
    }
    thanks!
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Often a little Google goes a long way.

    Read this and then look at your code: http://www.unixwiz.net/techtips/gnu-c-attributes.html.

    Comment

    Working...