From 6f5c3398592b4a3237952c20b06ae8a2e96e8c99 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Wed, 29 Aug 2018 20:14:36 +0100 Subject: [PATCH] Fix getopt-test to build on MSVC (which does not have unistd/getopt()) --- samples/getopt-test.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/samples/getopt-test.cpp b/samples/getopt-test.cpp index a75d8137..b8ba9878 100644 --- a/samples/getopt-test.cpp +++ b/samples/getopt-test.cpp @@ -23,8 +23,9 @@ #include #include "getopt.hpp" - +#ifdef EXV_HAVE_UNISTD_H #include +#endif #include #include #include @@ -82,6 +83,7 @@ int main(int argc, char** const argv) { int n; +#if EXV_HAVE_UNISTD_H std::cout << "standard getopt()" << std::endl; do { n = ::getopt(argc,argv,::optstring); @@ -98,6 +100,7 @@ int main(int argc, char** const argv) << std::endl; } while ( n >= 0 ); std::cout << std::endl; +#endif std::cout << "homemade getopt()" << std::endl; do { @@ -111,7 +114,7 @@ int main(int argc, char** const argv) std::cout << " optind = " << Util::optind << " opterr = " << Util::opterr << " optopt = " << Util::optopt - << " optarg = " << Safe(::optarg) + << " optarg = " << Safe(Util::optarg) << std::endl; } while ( n >= 0 );