bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: the signature of getopt, and getopt_long


From: Sergey Poznyakoff
Subject: Re: the signature of getopt, and getopt_long
Date: Sun, 27 Sep 2009 21:43:56 +0300

Hi Lorenzo,

> the
> 
> char * const *argv
> 
> libc declaration of getopt_long (which looks wrong, since argv might
> be changed during the parsing, right?)

Yes, it is wrong because argv might be permuted by getopt_long. And
that's why gnulib's implementation uses __getopt_argv_const in the
declaration (see the comment in lib/getopt.in.h:73).

> now, I'd like to avoid the warning in the generated parser when using
> gnulib, but I'd like to avoid it also when using libc getopt_long
> version...
> 
> what would you suggest?

I believe typecasting to `char *__getopt_argv_const *___argv' would be
the best way to handle this. Keep in mind, though, that
__getopt_argv_const is a macro, which is defined only if you include
gnulib's version of getopt.h. Perhaps some additional #ifdef magic
would be required before the cast, e.g.:

#ifndef __getopt_argv_const
# define __getopt_argv_const const
#endif

Regards,
Sergey




reply via email to

[Prev in Thread] Current Thread [Next in Thread]