]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
getopt: add const to interface
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 25 Feb 2009 19:27:09 +0000 (19:27 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 25 Feb 2009 19:27:09 +0000 (19:27 +0000)
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

trunk/etc/user/getopt.c
trunk/inc/user/getopt.h

index c8afc56d4f12bbae88b1e386e426d19da4ece6db..1282f1b18bd20b96547516aff4f73882f918749f 100644 (file)
@@ -39,7 +39,7 @@ int optind = 1;
 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
@@ -88,7 +88,7 @@ out:
        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
index 2a5367c02dfdbdade0d3fb2ec86a733818614f64..2f2e9a727ec419a4e4da7e74f80de1455a731a75 100644 (file)
 #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
@@ -51,8 +56,12 @@ enum
        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