commit:     ca282deea01374d6f01746432ce3f450bcf6ac9f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 23 20:16:58 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 23 20:16:58 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ca282dee

getopt: add workaround for Solaris to silence compiler

 porting.h | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/porting.h b/porting.h
index 206c6e3..b0225df 100644
--- a/porting.h
+++ b/porting.h
@@ -32,7 +32,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <fnmatch.h>
-#include <getopt.h>
 #include <glob.h>
 #include <inttypes.h>
 #include <libgen.h>
@@ -52,6 +51,24 @@
 
 #include <iniparser.h>
 
+#if defined(__sun) && defined(__SVR4)
+/* workaround non-const defined name in option struct, such that we
+ * don't get a zillion of warnings */
+#define        no_argument             0
+#define        required_argument       1
+#define        optional_argument       2
+struct option {
+       const char *name;
+       int has_arg;
+       int *flag;
+       int val;
+};
+extern int     getopt_long(int, char * const *, const char *,
+                   const struct option *, int *);
+#else
+#include <getopt.h>
+#endif
+
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(*(arr)))
 
 #ifndef BUFSIZE

Reply via email to