Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers LCC > Re: Unused para...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 965 of 1070
Post > Topic >>

Re: Unused parameters

by "Charlie Gordon" <news@[EMAIL PROTECTED] > Sep 3, 2007 at 11:17 AM

"jacob navia" <jacob@[EMAIL PROTECTED]
> a écrit dans le message de news: 
46a11369$0$25923$ba4acef3@[EMAIL PROTECTED]
> Hi
> I have extended lcc-win32 to recognize the syntax
>
> int fn(int a,int b,double)
> {
> // body of the function
> }
>
> This means that the third parameter is not used within
> the function.
>
> I would like to know your opinion about this extension before I
> generalize it in the next release.

Hi Jacob,

I don't have a strong opinion on whether you should advertise this
extension 
in the next version and encourage its use.  As far as I understand, it is 
already part of C++ but not C99.

On the other hand, unused function parameters are quite common in C. 
Having 
to do***ent them with awkward UNUSED macros, pragmas, attributes or
similar 
non ****table constructs is a pain.  Worse even, using them in dummy 
statements such as `(void)param;' is definitely ugly.

At first, I thought removing the parameter name was a good solution, but
it 
tends to obfuscate the function prototype as the unused parameters' names
do 
convey useful information.  Consider for instance the main function: argc 
and argv are redundant, one can process the command line using argv alone,

yet omitting argc in the prototype would look awkward:

int main(int, char *argv[]) {
   ...
}

My recommendation in this matter is to provide fine control over warning 
generation as to allow users to disable the warning about "unused function

parameter" separately from other warnings about unused local variables, 
static variables...  If such is already the case, I think said warning 
should be disabled by default, while others should be enabled.  I don't
know 
how such configuration can be passed to lcc-win32, but pragmas are not the

correct way to do this.  Command line options or configuration files
(global 
and/or project specific) are a much better solution.

Cheers,

Chqrlie.
 




 3 Posts in Topic:
Unused parameters
jacob navia <jacob@[EM  2007-07-20 21:56:07 
Re: Unused parameters
Walter Banks <walter@[  2007-07-24 14:04:53 
Re: Unused parameters
"Charlie Gordon"  2007-09-03 11:17:38 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 14:32:15 CDT 2008.