]> git.mxchange.org Git - flightgear.git/commitdiff
Fixes for compiling with gcc 4.3
authortimoore <timoore>
Sun, 13 Apr 2008 21:12:36 +0000 (21:12 +0000)
committertimoore <timoore>
Sun, 13 Apr 2008 21:12:36 +0000 (21:12 +0000)
Include standard header files and qualify with std:: where needed.

Qualify various char parameters and variables with const.

13 files changed:
src/Airports/dynamicloader.cxx
src/Airports/runwayprefloader.cxx
src/Airports/runways.cxx
src/FDM/JSBSim/input_output/FGfdmSocket.cpp
src/FDM/YASim/Airplane.cpp
src/FDM/YASim/Airplane.hpp
src/FDM/YASim/FGFDM.cpp
src/FDM/YASim/FGFDM.hpp
src/FDM/YASim/yasim-test.cpp
src/GUI/gui.h
src/GUI/gui_funcs.cxx
src/Main/util.cxx
utils/GPSsmooth/UGear_command.cxx

index 53027f63d52c91b71b64cbb812e53f4aa9b4a23f..986b1dd39bc120307cf237c157e3b0615499aa54 100644 (file)
@@ -13,6 +13,8 @@
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 
+#include <cstdlib>
+
 #include "dynamicloader.hxx"
 
 FGAirportDynamicsXMLLoader::FGAirportDynamicsXMLLoader(FGAirportDynamics* dyn):
@@ -50,7 +52,7 @@ void  FGAirportDynamicsXMLLoader::startElement (const char * name, const XMLAttr
          //cout << "  " << atts.getName(i) << '=' << atts.getValue(i) << endl; 
          attname = atts.getName(i);
          if (attname == string("index"))
-           park.setIndex(atoi(atts.getValue(i)));
+           park.setIndex(std::atoi(atts.getValue(i)));
          else if (attname == string("type"))
            park.setType(atts.getValue(i));
         else if (attname == string("name"))
@@ -62,13 +64,13 @@ void  FGAirportDynamicsXMLLoader::startElement (const char * name, const XMLAttr
          else if (attname == string("lon"))
            park.setLongitude(atts.getValue(i)); 
          else if (attname == string("heading"))
-           park.setHeading(atof(atts.getValue(i)));
+           park.setHeading(std::atof(atts.getValue(i)));
          else if (attname == string("radius")) {
            string radius = atts.getValue(i);
            if (radius.find("M") != string::npos)
              radius = radius.substr(0, radius.find("M",0));
            //cerr << "Radius " << radius <<endl;
-           park.setRadius(atof(radius.c_str()));
+           park.setRadius(std::atof(radius.c_str()));
          }
           else if (attname == string("airlineCodes"))
             park.setCodes(atts.getValue(i));
@@ -82,13 +84,13 @@ void  FGAirportDynamicsXMLLoader::startElement (const char * name, const XMLAttr
        {
          attname = atts.getName(i);
          if (attname == string("index"))
-           taxiNode.setIndex(atoi(atts.getValue(i)));
+           taxiNode.setIndex(std::atoi(atts.getValue(i)));
          if (attname == string("lat"))
            taxiNode.setLatitude(atts.getValue(i));
          if (attname == string("lon"))
            taxiNode.setLongitude(atts.getValue(i));
          if (attname == string("isOnRunway"))
-            taxiNode.setOnRunway((bool) atoi(atts.getValue(i)));
+            taxiNode.setOnRunway((bool) std::atoi(atts.getValue(i)));
          if (attname == string("holdPointType")) {
             attval = atts.getValue(i);
             if (attval==string("none")) {
@@ -113,11 +115,11 @@ void  FGAirportDynamicsXMLLoader::startElement (const char * name, const XMLAttr
        {
          attname = atts.getName(i);
          if (attname == string("begin"))
-           taxiSegment.setStartNodeRef(atoi(atts.getValue(i)));
+           taxiSegment.setStartNodeRef(std::atoi(atts.getValue(i)));
          if (attname == string("end"))
-           taxiSegment.setEndNodeRef(atoi(atts.getValue(i)));
+           taxiSegment.setEndNodeRef(std::atoi(atts.getValue(i)));
           if (attname == string("isPushBackRoute"))
-           taxiSegment.setPushBackType((bool) atoi(atts.getValue(i)));
+           taxiSegment.setPushBackType((bool) std::atoi(atts.getValue(i)));
        }
       _dynamics->getGroundNetwork()->addSegment(taxiSegment);
     }
index 3819a39a8264f7872ce9e4e22fa89871aac274db..bfdcf8dd660d318c67c583c3fc0a311e82dae9c2 100644 (file)
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 
+#include <cstring>
+#include <cstdlib>
+
 #include <simgear/debug/logstream.hxx>
 
 #include "runwayprefloader.hxx"
 
+using namespace std;
+
 FGRunwayPreferenceXMLLoader::FGRunwayPreferenceXMLLoader(FGRunwayPreference* p):XMLVisitor(), _pref(p) {}
 
 void  FGRunwayPreferenceXMLLoader::startXML () {
index b5770fc829699b0abe45a186220c70556d1ee28f..c1b22452259df4cf70eeb705d176bbb1ea90f505 100644 (file)
@@ -25,8 +25,9 @@
 #  include <config.h>
 #endif
 
-#include <math.h>               // fabs()
-#include <stdio.h>              // sprintf()
+#include <cmath>               // fabs()
+#include <cstdio>              // sprintf()
+#include <cstdlib>             // atoi()
 
 #include <simgear/compiler.h>
 #include <simgear/debug/logstream.hxx>
index 37f29336ea310350aaeb2dca63b43b9694f93c27..c1a582699ae7ae09ccd09e1813957385916a19c2 100644 (file)
@@ -37,6 +37,8 @@ HISTORY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+#include <cstring>
+
 #include "FGfdmSocket.h"
 
 namespace JSBSim {
@@ -79,7 +81,7 @@ FGfdmSocket::FGfdmSocket(string address, int port)
       memset(&scktName, 0, sizeof(struct sockaddr_in));
       scktName.sin_family = AF_INET;
       scktName.sin_port = htons(port);
-      memcpy(&scktName.sin_addr, host->h_addr_list[0], host->h_length);
+      std::memcpy(&scktName.sin_addr, host->h_addr_list[0], host->h_length);
       int len = sizeof(struct sockaddr_in);
       if (connect(sckt, (struct sockaddr*)&scktName, len) == 0) {   // successful
         cout << "Successfully connected to socket for output ..." << endl;
@@ -113,7 +115,7 @@ FGfdmSocket::FGfdmSocket(int port)
   sckt = socket(AF_INET, SOCK_STREAM, 0);
 
   if (sckt >= 0) {  // successful
-    memset(&scktName, 0, sizeof(struct sockaddr_in));
+    std::memset(&scktName, 0, sizeof(struct sockaddr_in));
     scktName.sin_family = AF_INET;
     scktName.sin_port = htons(port);
     int len = sizeof(struct sockaddr_in);
index c6b5ae9252f4a8b2eea64349db706308ef9eec01..1b3fbd4ba8ebfa47c4b2980f57ce8dbb8e6ccefe 100644 (file)
@@ -417,7 +417,7 @@ float Airplane::getTailIncidence()
     return _tailIncidence;
 }
 
-char* Airplane::getFailureMsg()
+const char* Airplane::getFailureMsg()
 {
     return _failureMsg;
 }
index e0e53f4e51853f098f778203f9a2ce925eb6863d..913eb49edcc3126c379e4887164302eda52e5b4f 100644 (file)
@@ -90,7 +90,7 @@ public:
     float getCruiseAoA();
     float getTailIncidence();
     float getApproachElevator() { return _approachElevator.val; }
-    char* getFailureMsg();
+    const char* getFailureMsg();
 
     static void setupState(float aoa, float speed, float gla, State* s); // utility
 
@@ -172,7 +172,7 @@ private:
     float _cruiseAoA;
     float _tailIncidence;
     Control _approachElevator;
-    char* _failureMsg;
+    const char* _failureMsg;
 };
 
 }; // namespace yasim
index 5d68308f16dd5954979be80d951886807c4df54b..921fdcf6095ea61c67fb329cef8e6ab9f52fa2ae 100644 (file)
@@ -1013,7 +1013,7 @@ char* FGFDM::dup(const char* s)
     return s2;
 }
 
-int FGFDM::attri(XMLAttributes* atts, char* attr)
+int FGFDM::attri(XMLAttributes* atts, const char* attr)
 {
     if(!atts->hasAttribute(attr)) {
         SG_LOG(SG_FLIGHT,SG_ALERT,"Missing '" << attr <<
@@ -1023,14 +1023,14 @@ int FGFDM::attri(XMLAttributes* atts, char* attr)
     return attri(atts, attr, 0);
 }
 
-int FGFDM::attri(XMLAttributes* atts, char* attr, int def)
+int FGFDM::attri(XMLAttributes* atts, const char* attr, int def)
 {
     const char* val = atts->getValue(attr);
     if(val == 0) return def;
     else         return atol(val);
 }
 
-float FGFDM::attrf(XMLAttributes* atts, char* attr)
+float FGFDM::attrf(XMLAttributes* atts, const char* attr)
 {
     if(!atts->hasAttribute(attr)) {
         SG_LOG(SG_FLIGHT,SG_ALERT,"Missing '" << attr <<
@@ -1040,14 +1040,14 @@ float FGFDM::attrf(XMLAttributes* atts, char* attr)
     return attrf(atts, attr, 0);
 }
 
-float FGFDM::attrf(XMLAttributes* atts, char* attr, float def)
+float FGFDM::attrf(XMLAttributes* atts, const char* attr, float def)
 {
     const char* val = atts->getValue(attr);
     if(val == 0) return def;
     else         return (float)atof(val);    
 }
 
-double FGFDM::attrd(XMLAttributes* atts, char* attr)
+double FGFDM::attrd(XMLAttributes* atts, const char* attr)
 {
     if(!atts->hasAttribute(attr)) {
         SG_LOG(SG_FLIGHT,SG_ALERT,"Missing '" << attr <<
@@ -1057,7 +1057,7 @@ double FGFDM::attrd(XMLAttributes* atts, char* attr)
     return attrd(atts, attr, 0);
 }
 
-double FGFDM::attrd(XMLAttributes* atts, char* attr, double def)
+double FGFDM::attrd(XMLAttributes* atts, const char* attr, double def)
 {
     const char* val = atts->getValue(attr);
     if(val == 0) return def;
@@ -1075,7 +1075,7 @@ double FGFDM::attrd(XMLAttributes* atts, char* attr, double def)
 // Unfortunately, this usage creeped into existing configuration files
 // while I wasn't active, and it's going to be hard to remove.  Issue
 // a warning to nag people into changing their ways for now...
-bool FGFDM::attrb(XMLAttributes* atts, char* attr)
+bool FGFDM::attrb(XMLAttributes* atts, const char* attr)
 {
     const char* val = atts->getValue(attr);
     if(val == 0) return false;
index 1df2c4872cffbde1d09454568d5cb10275e8842c..0d5b43e379e9feee6a1291c4ee9d090bf910dce0 100644 (file)
@@ -49,13 +49,13 @@ private:
     bool eq(const char* a, const char* b);
     bool caseeq(const char* a, const char* b);
     char* dup(const char* s);
-    int attri(XMLAttributes* atts, char* attr);
-    int attri(XMLAttributes* atts, char* attr, int def); 
-    float attrf(XMLAttributes* atts, char* attr);
-    float attrf(XMLAttributes* atts, char* attr, float def); 
-    double attrd(XMLAttributes* atts, char* attr);
-    double attrd(XMLAttributes* atts, char* attr, double def); 
-    bool attrb(XMLAttributes* atts, char* attr);
+    int attri(XMLAttributes* atts, const char* attr);
+    int attri(XMLAttributes* atts, const char* attr, int def); 
+    float attrf(XMLAttributes* atts, const char* attr);
+    float attrf(XMLAttributes* atts, const char* attr, float def); 
+    double attrd(XMLAttributes* atts, const char* attr);
+    double attrd(XMLAttributes* atts, const char* attr, double def); 
+    bool attrb(XMLAttributes* atts, const char* attr);
 
     // The core Airplane object we manage.
     Airplane _airplane;
index cff1c1558dbec07683bc5a2fd6bf4d5e43a0a565..2fa6425267f2488eaaf3f5fe0926d8ee7ef36aa0 100644 (file)
@@ -1,5 +1,8 @@
 #include <stdio.h>
 
+#include <cstring>
+#include <cstdlib>
+
 #include <simgear/props/props.hxx>
 #include <simgear/xml/easyxml.hxx>
 
@@ -93,8 +96,8 @@ int main(int argc, char** argv)
     if(!a->getFailureMsg() && argc > 2 && strcmp(argv[2], "-g") == 0) {
         float alt = 5000, kts = 100;
         for(int i=3; i<argc; i++) {
-            if     (strcmp(argv[i], "-a") == 0) alt = atof(argv[++i]);
-            else if(strcmp(argv[i], "-s") == 0) kts = atof(argv[++i]);
+            if     (std::strcmp(argv[i], "-a") == 0) alt = std::atof(argv[++i]);
+            else if(std::strcmp(argv[i], "-s") == 0) kts = std::atof(argv[++i]);
             else return usage();
         }
         yasim_graph(a, alt, kts);
index bc27d9a305b517ea6f5b49ab0f27286a5ddc2bd1..02717d4084cdce6550dba96f3face6ae4df2a5a6 100644 (file)
@@ -67,17 +67,17 @@ extern void printScreen(puObject *);
 extern void helpCb(puObject *);
 
 typedef struct {
-        char *name;
+        const char *name;
         void (*fn)(puObject *);
 } __fg_gui_fn_t;
 extern const __fg_gui_fn_t __fg_gui_fn[];
 
 // GLOBAL COMMON DIALOG BOX TEXT STRINGS
-extern char *gui_msg_OK;     // "OK"
-extern char *gui_msg_NO;     // "NO"
-extern char *gui_msg_YES;    // "YES"
-extern char *gui_msg_CANCEL; // "CANCEL"
-extern char *gui_msg_RESET;  // "RESET"
+extern const char *gui_msg_OK;     // "OK"
+extern const char *gui_msg_NO;     // "NO"
+extern const char *gui_msg_YES;    // "YES"
+extern const char *gui_msg_CANCEL; // "CANCEL"
+extern const char *gui_msg_RESET;  // "RESET"
 
 // mouse.cxx
 extern void guiInitMouse(int width, int height);
index 6a57dc1d68611eb80b2bba7dc8edba723973ed4e..acad392eec52b5262895bf988955a5fde63fd906 100644 (file)
@@ -103,11 +103,11 @@ extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
 
 
 // TODO: remove after the last hardcoded dialog has died
-char *gui_msg_OK     = "OK";
-char *gui_msg_NO     = "NO";
-char *gui_msg_YES    = "YES";
-char *gui_msg_CANCEL = "CANCEL";
-char *gui_msg_RESET  = "RESET";
+const char *gui_msg_OK     = "OK";
+const char *gui_msg_NO     = "NO";
+const char *gui_msg_YES    = "YES";
+const char *gui_msg_CANCEL = "CANCEL";
+const char *gui_msg_RESET  = "RESET";
 
 
 const __fg_gui_fn_t __fg_gui_fn[] = {
index 6b916e862bb6434f098b76c5c81b233c95347a82..b61985ca62e4be35819f44c40ca945206959b225 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <math.h>
 
+#include <cstdlib>
+
 #include <vector>
 SG_USING_STD(vector);
 
@@ -112,7 +114,7 @@ fgExit (int status)
 #endif
 
     SG_LOG(SG_GENERAL, SG_INFO, "Exiting FlightGear with status " << status);
-    exit(status);
+    std::exit(status);
 }
 
 
index 7e64cc887f53bf2a4b0fc0fba669782ead199fc9..85485749fc59a9a83a8d4483c1d384ca2af3fad8 100644 (file)
@@ -1,3 +1,5 @@
+#include <cstring>
+
 #include "UGear_command.hxx"
 
 
@@ -18,7 +20,7 @@ static char calc_nmea_cksum(const char *sentence) {
 
     // cout << sentence << endl;
 
-    len = strlen(sentence);
+    len = std::strlen(sentence);
     sum = sentence[0];
     for ( i = 1; i < len; i++ ) {
         // cout << sentence[i];