Re: unused parameters
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.