Skip to content

Commit d30a846

Browse files
committed
fix compile warnings when using Visual Studio 2008
Reported by Dominik Meyer <meyerd@mytum.de>.
1 parent c0da030 commit d30a846

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

OptionParser.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <cstdlib>
1111
#include <algorithm>
1212
#include <complex>
13+
#include <ciso646>
1314

1415
#if defined(ENABLE_NLS) && ENABLE_NLS
1516
# include <libintl.h>
@@ -23,7 +24,8 @@ using namespace std;
2324
namespace optparse {
2425

2526
////////// auxiliary (string) functions { //////////
26-
struct str_wrap {
27+
class str_wrap {
28+
public:
2729
str_wrap(const string& l, const string& r) : lwrap(l), rwrap(r) {}
2830
str_wrap(const string& w) : lwrap(w), rwrap(w) {}
2931
string operator() (const string& s) { return lwrap + s + rwrap; }
@@ -99,9 +101,11 @@ static string str_inc(const string& s) {
99101
}
100102
static unsigned int cols() {
101103
unsigned int n = 80;
104+
#ifndef _WIN32
102105
const char *s = getenv("COLUMNS");
103106
if (s)
104107
istringstream(s) >> n;
108+
#endif
105109
return n;
106110
}
107111
static string basename(const string& s) {
@@ -427,7 +431,7 @@ void OptionParser::print_usage() const {
427431
string OptionParser::get_version() const {
428432
return str_replace(_version, "%prog", prog());
429433
}
430-
void OptionParser::print_version(std::ostream& out) const {
434+
void OptionParser::print_version(ostream& out) const {
431435
out << get_version() << endl;
432436
}
433437
void OptionParser::print_version() const {
@@ -450,7 +454,7 @@ const string& Values::operator[] (const string& d) const {
450454
static const string empty = "";
451455
return (it != _map.end()) ? it->second : empty;
452456
}
453-
void Values::is_set_by_user(const std::string& d, bool yes) {
457+
void Values::is_set_by_user(const string& d, bool yes) {
454458
if (yes)
455459
_userSet.insert(d);
456460
else

OptionParser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ class Option {
290290
friend class OptionParser;
291291
};
292292

293-
struct Callback {
293+
class Callback {
294+
public:
294295
virtual void operator() (const Option& option, const std::string& opt, const std::string& val, const OptionParser& parser) = 0;
295296
virtual ~Callback() {}
296297
};

test.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ using namespace std;
1010

1111
using namespace optparse;
1212

13-
struct Output {
13+
class Output {
14+
public:
1415
Output(const string& d) : delim(d), first(true) {}
1516
void operator() (const string& s) {
1617
if (first)
@@ -24,9 +25,10 @@ struct Output {
2425
bool first;
2526
};
2627

27-
struct MyCallback : public optparse::Callback {
28+
class MyCallback : public optparse::Callback {
29+
public:
2830
MyCallback() : counter(0) {}
29-
void operator() (const Option& option, const std::string& opt, const std::string& val, const OptionParser& parser) {
31+
void operator() (const Option& option, const string& opt, const string& val, const OptionParser& parser) {
3032
counter++;
3133
cout << "--- MyCallback --- " << counter << ". time called" << endl;
3234
cout << "--- MyCallback --- option.action(): " << option.action() << endl;

0 commit comments

Comments
 (0)