From: ehofman Date: Thu, 16 Oct 2003 12:51:47 +0000 (+0000) Subject: Fix a problem where older IRIX compilers needed a typecast for certain opperations X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3c08eae85b77e329d34245fa6f9200c08e52e3bb;p=simgear.git Fix a problem where older IRIX compilers needed a typecast for certain opperations --- diff --git a/simgear/compatibility/IRIX b/simgear/compatibility/IRIX new file mode 100644 index 00000000..1711739d --- /dev/null +++ b/simgear/compatibility/IRIX @@ -0,0 +1,43 @@ + +#ifndef __SGI_HXX +#define __SGI_HXX + +#include + +inline bool +operator!=( const std::string& lhs, const char* rhs) +{ + return lhs.compare( rhs ) != 0; +} + +inline bool +operator!=( const char* lhs, const std::string& rhs) +{ + return rhs.compare( lhs ) != 0; +} + +inline bool +operator==( const std::string& lhs, const char* rhs) +{ + return lhs.compare( rhs ) == 0; +} + +inline bool +operator==( const char* lhs, const std::string& rhs) +{ + return rhs.compare( lhs ) == 0; +} + +inline std::string +operator+(const std::string& lhs, const char* rhs) +{ + return lhs + std::string(rhs); +} + +inline std::string +operator+(const char* lhs, const std::string& rhs) +{ + return std::string(lhs) + rhs; +} + +#endif // !__SGI_HXX diff --git a/simgear/compatibility/Makefile.am b/simgear/compatibility/Makefile.am index 25427d3e..7cdc91e4 100644 --- a/simgear/compatibility/Makefile.am +++ b/simgear/compatibility/Makefile.am @@ -28,4 +28,6 @@ include_HEADERS = \ ctime \ iomanip \ new \ - streambuf + streambuf \ + \ + IRIX diff --git a/simgear/compiler.h b/simgear/compiler.h index 6fd52c5e..9bf82093 100644 --- a/simgear/compiler.h +++ b/simgear/compiler.h @@ -290,6 +290,8 @@ #if defined ( sgi ) && !defined( __GNUC__ ) # define SG_HAVE_NATIVE_SGI_COMPILERS +#include + # define SG_EXPLICIT_FUNCTION_TMPL_ARGS # define SG_CLASS_PARTIAL_SPECIALIZATION # define SG_NEED_AUTO_PTR diff --git a/simgear/io/sg_socket.cxx b/simgear/io/sg_socket.cxx index 20238727..0ac45a80 100644 --- a/simgear/io/sg_socket.cxx +++ b/simgear/io/sg_socket.cxx @@ -54,7 +54,7 @@ SGSocket::SGSocket( const string& host, const string& port_, { is_tcp = true; } - else if ( style != (string)"udp" ) + else if ( style != "udp" ) { SG_LOG( SG_IO, SG_ALERT, "Error: SGSocket() unknown style = " << style ); diff --git a/simgear/misc/tabbed_values_test.cxx b/simgear/misc/tabbed_values_test.cxx index 90825009..0a5dfee0 100644 --- a/simgear/misc/tabbed_values_test.cxx +++ b/simgear/misc/tabbed_values_test.cxx @@ -18,17 +18,17 @@ int main (int ac, char ** av) SGTabbedValues tv(string1); - if (tv[0] != string("Hello")) { + if (tv[0] != "Hello") { cerr << "failed to read string at index 0" << endl; return 1; } - if (tv[1] != string("World")) { + if (tv[1] != "World") { cerr << "failed to read string at index 1" << endl; return 1; } - if (tv[2] != string("34")) { + if (tv[2] != "34") { cerr << "failed to read string at index 2" << endl; return 1; } @@ -61,7 +61,7 @@ int main (int ac, char ** av) return 3; } - if (tv[5] != string("There Is No Spoon")) { + if (tv[5] != "There Is No Spoon") { cerr << "failed to read string at index 5 (got [" << tv[5] << "]" << endl; return 1; } diff --git a/simgear/props/props.cxx b/simgear/props/props.cxx index 790aa05c..c6f5145b 100644 --- a/simgear/props/props.cxx +++ b/simgear/props/props.cxx @@ -113,7 +113,7 @@ parse_name (const string &path, int &i) name = "."; } if (i < max && path[i] != '/') - throw string(string("Illegal character after ") + name); + throw string("Illegal character after " + name); } else if (isalpha(path[i]) || path[i] == '_') { diff --git a/simgear/props/props_io.cxx b/simgear/props/props_io.cxx index e808e0b6..92781ea6 100644 --- a/simgear/props/props_io.cxx +++ b/simgear/props/props_io.cxx @@ -117,9 +117,9 @@ checkFlag (const char * flag, bool defaultState = true) { if (flag == 0) return defaultState; - else if (string(flag) == "y") + else if (flag == "y") return true; - else if (string(flag) == "n") + else if (flag == "n") return false; else { string message = "Unrecognized flag value '"; @@ -137,7 +137,7 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts) const char * attval; if (_level == 0) { - if (string(name) != (string)"PropertyList") { + if (name != "PropertyList") { string message = "Root element name is "; message += name; message += "; expected PropertyList"; diff --git a/simgear/structure/exception.cxx b/simgear/structure/exception.cxx index 75f4cf50..d7c83b08 100644 --- a/simgear/structure/exception.cxx +++ b/simgear/structure/exception.cxx @@ -86,7 +86,7 @@ sg_location::asString () const { char buf[128]; string out = ""; - if (_path != (string)"") { + if (!_path.empty()) { out += _path; if (_line != -1 || _column != -1) out += ",\n";