On Sun, 25 Apr 2010, Dagobert Michelsen wrote:
> However, I had the impression you wanted to
> implement different checking for cc and CC?
I thought that would be the most general solution, but the consensus
appears to be that gnulib should not have to handle this.
On Mon, 26 Apr 2010, Bruno Haible wrote:
> So here's my suggestion. Change /opt/csw/include/getopt.h like this, and be
> done with it.
That worked for me. Thanks, and thanks to everyone who has offered their
help on this issue.
> All the __STDC__ checks can be removed. No one uses K&R C
> nowadays any more. Only ANSI/ISO C and C++ are relevant.
I completely trust Bruno's opinion on this point, and I know of no reason
to keep the __STDC__ checks. However, Dago, in case dropping the __STDC__
checks gives you some reason for concern, below is an alternate patch that
avoids that change. It is against current9s:/opt/csw/include/getopt.h.
By the way, I finally realized that, like CC, g++ sets __STDC__ to 0 for
system headers on Solaris, so this patch uses __sun not __SUNPRO_CC in the
__STDC__ checks. I've tested this patch with g++ 3.4.6 and CC, both on
Solaris 5.9.
--- /opt/csw/include/getopt.h Mon Jan 18 11:37:54 2010
+++ getopt.h Mon Apr 26 07:42:38 2010
@@ -80,7 +80,7 @@
struct option
{
-#if defined (__STDC__) && __STDC__
+#if defined (__STDC__) && (__STDC__ || defined __sun)
const char *name;
#else
char *name;
@@ -98,15 +98,16 @@
#define required_argument 1
#define optional_argument 2
-#if defined (__STDC__) && __STDC__
-#ifdef __GNU_LIBRARY__
+
+#if defined (__STDC__) && (__STDC__ || defined __sun)
+#if defined __GNU_LIBRARY__ || defined __sun
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
- errors, only prototype getopt for the GNU C library. */
+ errors, only prototype getopt for the GNU C library and for Solaris. */
extern int getopt (int argc, char *const *argv, const char *shortopts);
-#else /* not __GNU_LIBRARY__ */
+#else /* not __GNU_LIBRARY__ || __sun */
extern int getopt ();
-#endif /* __GNU_LIBRARY__ */
+#endif /* __GNU_LIBRARY__ || __sun */
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind);
extern int getopt_long_only (int argc, char *const *argv,