• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: unused parameters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unused parameters


  • Subject: Re: unused parameters
  • From: Sailor Quasar <email@hidden>
  • Date: Sat, 27 Sep 2003 17:05:22 -0400

On Saturday, September 27, 2003, at 04:42 PM, David Remahl wrote:
GCC supports the same pragma:

#pragma unused( var )

Absolutely true. However this pragma, and in fact #pragmas in general are deprecated in gcc and exist only for compatibility. If you're using gcc exclusively, you should instead use the following syntax:

// Function prototype
void f1(int some_unused_param);

// Function definition
void f1(int __attribute__((__unused__)) some_unused_param)
{
// function body
}

This also works on variables...
int __attribute__((__unused__)) some_unused_var;

... and on functions themselves...
// Function prototype
void some_unused_function() __attribute__((__unused__));

// Function definition
void some_unused_function()
{
// function body
}

There has been debate over whether the attribute syntax or the #pragma syntax is better. I personally prefer the attribute syntax, as you can setup attribute usage with macros, whereas #pragmas must exist in the original file (preprocessor directives can not be generated by macros).

On 27 sep 2003, at 22.36, Danny Swarzman wrote:
Does anyone know how to surpress warnings about unused parameters.

CodeWarrior has a #pragma for this.

I haven't found anything about this in the docs.

-Danny

-- Sailor Quasar, just another player in The World
"Come with me in the twilight of the summer night for awhile"
Email: email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: unused parameters
      • From: "Alastair J.Houghton" <email@hidden>
    • Re: unused parameters
      • From: "Alastair J.Houghton" <email@hidden>
References: 
 >Re: unused parameters (From: David Remahl <email@hidden>)

  • Prev by Date: Re: unused parameters
  • Next by Date: Re: unused parameters
  • Previous by thread: Re: unused parameters
  • Next by thread: Re: unused parameters
  • Index(es):
    • Date
    • Thread