diff --git a/acsite.m4 b/acsite.m4 index 3a0e116e..dd9c8e13 100644 --- a/acsite.m4 +++ b/acsite.m4 @@ -392,3 +392,24 @@ if test "$have_timezone" = no; then AC_MSG_RESULT(no)) fi ])dnl + +## AC_BZ_SET_COMPILER: Addition by Theodore Papadopoulo +## Patch by Jim McKelvey: change sed -e 's/ /@/g' to sed -e 's/ /@/' +AC_DEFUN(AC_SG_SET_COMPILER, + [cxxwith=`echo $1 | sed -e 's/ /@/'` + case "$cxxwith" in + *:*@*) # Full initialization syntax + CXX=`echo "$cxxwith" | sed -n -e 's/.*:\(.*\)@.*/\1/p'` + CXXFLAGS=`echo "$cxxwith" | sed -n -e 's/.*:.*@\(.*\)/\1/p'` + ;; + *:*) # Simple initialization syntax + CXX=`echo "$cxxwith" | sed -n -e 's/.*:\(.*\)/\1/p'` + CXXFLAGS=$3 + ;; + *) # Default values + CXX=$2 + CXXFLAGS=$3 + CC="$2 --c" +## CFLAGS= + ;; + esac]) diff --git a/configure.in b/configure.in index 9181d6d8..5b5aab82 100644 --- a/configure.in +++ b/configure.in @@ -8,6 +8,23 @@ AC_INIT(simgear/bucket/newbucket.cxx) dnl Initialize the automake stuff AM_INIT_AUTOMAKE(SimGear, 0.0.14) +dnl Specify KAI C++ compiler and flags. +dnl Borrowed with slight modification from blitz distribution. +AC_ARG_WITH(cxx, + [ --with-cxx=COMPILER[:name-flags] set options for COMPILER (KCC)], + [case "$withval" in + KCC*) # KAI C++ http://www.kai.com/ + echo "Configuring for KAI C++" + AC_SG_SET_COMPILER($withval,"KCC","--restrict --strict_warnings") + CXX_OPTIMIZE_FLAGS=="+K3 -O3" + CXX_DEBUG_FLAGS="-g +K0" + ;; + esac +]) + +echo CXX = $CXX +echo CC = $CC + dnl Checks for programs. AC_PROG_MAKE_SET AC_PROG_CC diff --git a/simgear/compiler.h b/simgear/compiler.h index 1cad5dfb..e50a5c43 100644 --- a/simgear/compiler.h +++ b/simgear/compiler.h @@ -94,6 +94,25 @@ # endif #endif +/* KAI C++ */ +#if defined(__KCC) + +# define FG_NAMESPACES +# define FG_HAVE_STD +# define FG_HAVE_STREAMBUF +# define FG_HAVE_TRAITS +# define FG_HAVE_STD_INCLUDES + +# define STL_ALGORITHM +# define STL_FUNCTIONAL +# define STL_IOMANIP +# define STL_IOSTREAM +# define STL_FSTREAM +# define STL_STDEXCEPT +# define STL_STRING +# define STL_STRSTREAM +#endif + // // Metrowerks // diff --git a/simgear/ephemeris/celestialBody.cxx b/simgear/ephemeris/celestialBody.cxx index 053dfe83..7e9a463c 100644 --- a/simgear/ephemeris/celestialBody.cxx +++ b/simgear/ephemeris/celestialBody.cxx @@ -108,7 +108,7 @@ void CelestialBody::updatePosition(double mjd, Star *ourSun) } FV = RAD_TO_DEG * acos( tmp ); -}; +} /**************************************************************************** * double CelestialBody::sgCalcEccAnom(double M, double e) diff --git a/simgear/ephemeris/celestialBody.hxx b/simgear/ephemeris/celestialBody.hxx index 9311b78c..d32a16ed 100644 --- a/simgear/ephemeris/celestialBody.hxx +++ b/simgear/ephemeris/celestialBody.hxx @@ -121,7 +121,7 @@ inline CelestialBody::CelestialBody(double Nf, double Ns, eFirst = ef; eSec = es; MFirst = Mf; MSec = Ms; updateOrbElements(mjd); -}; +} inline CelestialBody::CelestialBody(double Nf, double Ns, double If, double Is, @@ -136,7 +136,7 @@ inline CelestialBody::CelestialBody(double Nf, double Ns, aFirst = af; aSec = as; eFirst = ef; eSec = es; MFirst = Mf; MSec = Ms; -}; +} /**************************************************************************** * inline void CelestialBody::updateOrbElements(double mjd) diff --git a/simgear/io/sg_file.cxx b/simgear/io/sg_file.cxx index 4707c397..055648c0 100644 --- a/simgear/io/sg_file.cxx +++ b/simgear/io/sg_file.cxx @@ -50,19 +50,13 @@ SGFile::~SGFile() { bool SGFile::open( SGProtocolDir dir ) { if ( dir == SG_IO_OUT ) { #ifdef _MSC_VER - fp = _open( file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC, - 00666 ); + int mode = 00666; #else - fp = std::open( file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC, - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | - S_IROTH | S_IWOTH ); + mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; #endif + fp = ::open( file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC, mode ); } else if ( dir == SG_IO_IN ) { -#ifdef _MSC_VER - fp = _open( file_name.c_str(), O_RDONLY ); -#else - fp = std::open( file_name.c_str(), O_RDONLY ); -#endif + fp = ::open( file_name.c_str(), O_RDONLY ); } else { FG_LOG( FG_IO, FG_ALERT, "Error: bidirection mode not available for files." ); @@ -81,13 +75,7 @@ bool SGFile::open( SGProtocolDir dir ) { // read a block of data of specified size int SGFile::read( char *buf, int length ) { // read a chunk -#ifdef _MSC_VER - int result = _read( fp, buf, length ); -#else - int result = std::read( fp, buf, length ); -#endif - - return result; + return ::read( fp, buf, length ); } @@ -97,11 +85,7 @@ int SGFile::readline( char *buf, int length ) { int pos = lseek( fp, 0, SEEK_CUR ); // read a chunk -#ifdef _MSC_VER - int result = _read( fp, buf, length ); -#else - int result = std::read( fp, buf, length ); -#endif + int result = ::read( fp, buf, length ); // find the end of line and reset position int i; @@ -122,11 +106,7 @@ int SGFile::readline( char *buf, int length ) { // write data to a file int SGFile::write( char *buf, int length ) { -#ifdef _MSC_VER - int result = _write( fp, buf, length ); -#else - int result = std::write( fp, buf, length ); -#endif + int result = ::write( fp, buf, length ); if ( result != length ) { FG_LOG( FG_IO, FG_ALERT, "Error writing data: " << file_name ); } @@ -144,11 +124,7 @@ int SGFile::writestring( char *str ) { // close the port bool SGFile::close() { -#ifdef _MSC_VER - if ( _close( fp ) == -1 ) { -#else - if ( std::close( fp ) == -1 ) { -#endif + if ( ::close( fp ) == -1 ) { return false; }