From: shefty Date: Wed, 25 Feb 2009 19:27:09 +0000 (+0000) Subject: getopt: add const to interface X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=a93a1939f8d008e47a82681ee0a2ac8ec3f28c6d;p=~shefty%2Frdma-win.git getopt: add const to interface 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 git-svn-id: svn://openib.tc.cornell.edu/gen1@1989 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/trunk/etc/user/getopt.c b/trunk/etc/user/getopt.c index c8afc56d..1282f1b1 100644 --- a/trunk/etc/user/getopt.c +++ b/trunk/etc/user/getopt.c @@ -39,7 +39,7 @@ int optind = 1; int opterr = 1; int optopt = '?'; -int getopt(int argc, char **argv, char const *opts) +int getopt(int argc, char * const argv[], char const *opts) { char *loc; @@ -88,7 +88,7 @@ out: return optopt; } -int getopt_long(int argc, char **argv, char const *opts, +int getopt_long(int argc, char * const argv[], char const *opts, const struct option *longopts, int *longindex) { char arg[256]; diff --git a/trunk/inc/user/getopt.h b/trunk/inc/user/getopt.h index 2a5367c0..2f2e9a72 100644 --- a/trunk/inc/user/getopt.h +++ b/trunk/inc/user/getopt.h @@ -31,6 +31,11 @@ #ifndef _GETOPT_H_ #define _GETOPT_H_ +#ifdef __cplusplus +extern "C" +{ +#endif + extern char *optarg; extern int optind; extern int opterr; @@ -51,8 +56,12 @@ enum optional_argument }; -extern int getopt(int argc, char **argv, char const *opts); -extern int getopt_long(int argc, char **argv, char const *opts, +extern int getopt(int argc, char * const argv[], char const *opts); +extern int getopt_long(int argc, char * const argv[], char const *opts, const struct option *longopts, int *longindex); +#ifdef __cplusplus +} // extern "C" +#endif + #endif