Add const to getopt argv argument, and allow getopt to be included by
c++.
This allows the ib-diags to call getopt without build warnings.
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1@1989
ad392aa1-c5ef-ae45-8dd8-
e69d62a5ef86
int opterr = 1;\r
int optopt = '?';\r
\r
-int getopt(int argc, char **argv, char const *opts)\r
+int getopt(int argc, char * const argv[], char const *opts)\r
{\r
char *loc;\r
\r
return optopt;\r
}\r
\r
-int getopt_long(int argc, char **argv, char const *opts,\r
+int getopt_long(int argc, char * const argv[], char const *opts,\r
const struct option *longopts, int *longindex)\r
{\r
char arg[256];\r
#ifndef _GETOPT_H_\r
#define _GETOPT_H_\r
\r
+#ifdef __cplusplus\r
+extern "C"\r
+{\r
+#endif\r
+\r
extern char *optarg;\r
extern int optind;\r
extern int opterr;\r
optional_argument\r
};\r
\r
-extern int getopt(int argc, char **argv, char const *opts);\r
-extern int getopt_long(int argc, char **argv, char const *opts,\r
+extern int getopt(int argc, char * const argv[], char const *opts);\r
+extern int getopt_long(int argc, char * const argv[], char const *opts,\r
const struct option *longopts, int *longindex);\r
\r
+#ifdef __cplusplus\r
+} // extern "C"\r
+#endif\r
+\r
#endif\r