diff --git a/examples/Makefile.am b/examples/Makefile.am index 10063b0..12db091 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,5 +1,5 @@ -noinst_PROGRAMS = test1 test2 test3 test4 test5 test6 test7 test8 test9 +noinst_PROGRAMS = test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test1_SOURCES = test1.cpp test2_SOURCES = test2.cpp @@ -10,6 +10,7 @@ test6_SOURCES = test6.cpp test7_SOURCES = test7.cpp test8_SOURCES = test8.cpp test9_SOURCES = test9.cpp +test10_SOURCES = test10.cpp INCLUDES = -I$(top_srcdir)/include diff --git a/examples/test10.cpp b/examples/test10.cpp new file mode 100644 index 0000000..6ef71c4 --- /dev/null +++ b/examples/test10.cpp @@ -0,0 +1,26 @@ +// Test only makes sure we can use different argv types for the +// parser. Don't run, just compile. + +#include "tclap/CmdLine.h" + +using namespace TCLAP; +int main() +{ + char *argv5[] = {"Foo", 0}; + const char *argv6[] = {"Foo", 0}; + const char * const argv7[] = {"Foo", 0}; + char **argv1 = argv5; + const char **argv2 = argv6; + const char * const * argv3 = argv7; + const char * const * const argv4 = argv7; + + CmdLine cmd("Command description message", ' ', "0.9"); + cmd.parse(0, argv1); + cmd.parse(0, argv2); + cmd.parse(0, argv3); + cmd.parse(0, argv4); + cmd.parse(0, argv5); + cmd.parse(0, argv6); + cmd.parse(0, argv7); +} + diff --git a/include/tclap/CmdLine.h b/include/tclap/CmdLine.h index 7d39cca..1d80b94 100644 --- a/include/tclap/CmdLine.h +++ b/include/tclap/CmdLine.h @@ -227,7 +227,7 @@ private: * \param argc - Number of arguments. * \param argv - Array of arguments. */ - void parse(int argc, char** argv); + void parse(int argc, const char * const * argv); /** * Parses the command line. @@ -391,7 +391,7 @@ inline void CmdLine::add( Arg* a ) } -inline void CmdLine::parse(int argc, char** argv) +inline void CmdLine::parse(int argc, const char * const * argv) { // this step is necessary so that we have easy access to // mutable strings. diff --git a/include/tclap/CmdLineInterface.h b/include/tclap/CmdLineInterface.h index af7f310..e3f73fd 100644 --- a/include/tclap/CmdLineInterface.h +++ b/include/tclap/CmdLineInterface.h @@ -82,7 +82,7 @@ class CmdLineInterface * \param argc - Number of arguments. * \param argv - Array of arguments. */ - virtual void parse(int argc, char** argv)=0; + virtual void parse(int argc, const char * const * argv)=0; /** * Parses the command line.