[comp.lang.c++] getting rid of---"prog.c": line nnn: warning: var not used

csuvt@warwick.ac.uk (Anton Carver (Wands)) (06/02/89)

Have you ever written a program like this:

main ( int argc, char *argv[] ) 
{
	/* do something with argv, but not argc */
}

and the warning:
"prog.c": line 4: warning: argc not used

The solution:

main ( int, char *argv[] )
{
	/* do something with argv, but not argc */
}

Obvious really, but not to many C programmers.

shap@polya.Stanford.EDU (Jonathan S. Shapiro) (06/03/89)

In article <115@orchid.warwick.ac.uk> csuvt@warwick.ac.uk (Anton Carver (Wands)) writes:
>and the warning:
>"prog.c": line 4: warning: argc not used
>
>The solution:
>
>main ( int, char *argv[] )
>{
>	/* do something with argv, but not argc */
>}

We have adopted a slightly different solution, which preserves some
documentation value:

main ( int /* argc */, char *argv[] )
{
	/* do something with argv, but not argc */
}

It achieves the same purpose without loss of any information.

Jon