Tobias Blass <> writes:
> On Sun, 6 Feb 2011, Johannes Schaub (litb) wrote:
>>Tobias Blass wrote:
>>
>>> Hi all,
>>> I'm just reading fetchmail source code and found the following lines
>>> /* env.c, line 37 */
>>> void envquery(int argc,char **argv)
>>> {
>>> /* ... */
>>> (void)argc;
>>> (void)argc;
>>> /*...*/
>>> }
>>>
>>> envquery is called (from main()) like this
>>>
>>> envquery(argc,argv);
>>>
>>> I don't really get the sense of these two (void)argc; . Does this have
>>> any special meaning or is it really "take the value of argc and ignore
>>> it"?
>>
>>Noone has yet pointed out that only the first (void)argc; really is useful.
>>The second (void)argc; is really without sense. I suspect that's a typo, and
>>the second one should be (void)argv;.
>>
> This wouldn't make sense either, since argv is used in the function in every
> case (not only in possible #ifdef branches or something). You can see it in the
> fetchmail source code if you wannt to see it 8I don't want to post the entire
> 100 lines function here)
So it's a (harmless) error in the fetchmail source. If neither argc nor
argv were used, it would make sense to have
(void)argc;
(void)argv;
Since argv is used but argc isn't, it would make sense to have:
(void)argc;
There's no particular reason for the compiler to warn about it, so it
was missed.
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"