bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] getopt: avoid compiler warning during configure


From: Paul Eggert
Subject: Re: [PATCH] getopt: avoid compiler warning during configure
Date: Thu, 07 Jul 2011 14:26:45 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Thunderbird/3.1.10

On 07/07/11 10:10, Eric Blake wrote:
> -               if (getopt (3, argv, "W;") != 'W')
> +               if (getopt (3, (char **) argv, "W;") != 'W')

I dunno, adding those casts doesn't
seem like much of an improvement.  What if some other
compiler starts complaining about them?

How about this idea instead?  Don't insert any casts,
and don't add any "const" keywords.  Instead, replace
stuff like this:

   char *argv[3] = { "program", "-ab", NULL };

with stuff like this:

   static char program[] = "program";
   static char x_ab[] = "-ab";
   char *argv[3] = { program, x_ab, NULL };

This will pacify the compiler.  It's a bit awkward,
but it's bound to be more portable than the casts are.



reply via email to

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