1
0
Fork 0

Fixes for compiling with gcc 4.3

Include standard header files and qualify with std:: where needed.

Qualify various char parameters and variables with const.
This commit is contained in:
timoore 2008-04-13 21:12:36 +00:00
parent 3bc15df56b
commit ebf2e996e9
13 changed files with 61 additions and 44 deletions

View file

@ -13,6 +13,8 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// //
#include <cstdlib>
#include "dynamicloader.hxx" #include "dynamicloader.hxx"
FGAirportDynamicsXMLLoader::FGAirportDynamicsXMLLoader(FGAirportDynamics* dyn): FGAirportDynamicsXMLLoader::FGAirportDynamicsXMLLoader(FGAirportDynamics* dyn):
@ -50,7 +52,7 @@ void FGAirportDynamicsXMLLoader::startElement (const char * name, const XMLAttr
//cout << " " << atts.getName(i) << '=' << atts.getValue(i) << endl; //cout << " " << atts.getName(i) << '=' << atts.getValue(i) << endl;
attname = atts.getName(i); attname = atts.getName(i);
if (attname == string("index")) if (attname == string("index"))
park.setIndex(atoi(atts.getValue(i))); park.setIndex(std::atoi(atts.getValue(i)));
else if (attname == string("type")) else if (attname == string("type"))
park.setType(atts.getValue(i)); park.setType(atts.getValue(i));
else if (attname == string("name")) else if (attname == string("name"))
@ -62,13 +64,13 @@ void FGAirportDynamicsXMLLoader::startElement (const char * name, const XMLAttr
else if (attname == string("lon")) else if (attname == string("lon"))
park.setLongitude(atts.getValue(i)); park.setLongitude(atts.getValue(i));
else if (attname == string("heading")) else if (attname == string("heading"))
park.setHeading(atof(atts.getValue(i))); park.setHeading(std::atof(atts.getValue(i)));
else if (attname == string("radius")) { else if (attname == string("radius")) {
string radius = atts.getValue(i); string radius = atts.getValue(i);
if (radius.find("M") != string::npos) if (radius.find("M") != string::npos)
radius = radius.substr(0, radius.find("M",0)); radius = radius.substr(0, radius.find("M",0));
//cerr << "Radius " << radius <<endl; //cerr << "Radius " << radius <<endl;
park.setRadius(atof(radius.c_str())); park.setRadius(std::atof(radius.c_str()));
} }
else if (attname == string("airlineCodes")) else if (attname == string("airlineCodes"))
park.setCodes(atts.getValue(i)); park.setCodes(atts.getValue(i));
@ -82,13 +84,13 @@ void FGAirportDynamicsXMLLoader::startElement (const char * name, const XMLAttr
{ {
attname = atts.getName(i); attname = atts.getName(i);
if (attname == string("index")) if (attname == string("index"))
taxiNode.setIndex(atoi(atts.getValue(i))); taxiNode.setIndex(std::atoi(atts.getValue(i)));
if (attname == string("lat")) if (attname == string("lat"))
taxiNode.setLatitude(atts.getValue(i)); taxiNode.setLatitude(atts.getValue(i));
if (attname == string("lon")) if (attname == string("lon"))
taxiNode.setLongitude(atts.getValue(i)); taxiNode.setLongitude(atts.getValue(i));
if (attname == string("isOnRunway")) if (attname == string("isOnRunway"))
taxiNode.setOnRunway((bool) atoi(atts.getValue(i))); taxiNode.setOnRunway((bool) std::atoi(atts.getValue(i)));
if (attname == string("holdPointType")) { if (attname == string("holdPointType")) {
attval = atts.getValue(i); attval = atts.getValue(i);
if (attval==string("none")) { if (attval==string("none")) {
@ -113,11 +115,11 @@ void FGAirportDynamicsXMLLoader::startElement (const char * name, const XMLAttr
{ {
attname = atts.getName(i); attname = atts.getName(i);
if (attname == string("begin")) if (attname == string("begin"))
taxiSegment.setStartNodeRef(atoi(atts.getValue(i))); taxiSegment.setStartNodeRef(std::atoi(atts.getValue(i)));
if (attname == string("end")) if (attname == string("end"))
taxiSegment.setEndNodeRef(atoi(atts.getValue(i))); taxiSegment.setEndNodeRef(std::atoi(atts.getValue(i)));
if (attname == string("isPushBackRoute")) if (attname == string("isPushBackRoute"))
taxiSegment.setPushBackType((bool) atoi(atts.getValue(i))); taxiSegment.setPushBackType((bool) std::atoi(atts.getValue(i)));
} }
_dynamics->getGroundNetwork()->addSegment(taxiSegment); _dynamics->getGroundNetwork()->addSegment(taxiSegment);
} }

View file

@ -13,10 +13,15 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// //
#include <cstring>
#include <cstdlib>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include "runwayprefloader.hxx" #include "runwayprefloader.hxx"
using namespace std;
FGRunwayPreferenceXMLLoader::FGRunwayPreferenceXMLLoader(FGRunwayPreference* p):XMLVisitor(), _pref(p) {} FGRunwayPreferenceXMLLoader::FGRunwayPreferenceXMLLoader(FGRunwayPreference* p):XMLVisitor(), _pref(p) {}
void FGRunwayPreferenceXMLLoader::startXML () { void FGRunwayPreferenceXMLLoader::startXML () {

View file

@ -25,8 +25,9 @@
# include <config.h> # include <config.h>
#endif #endif
#include <math.h> // fabs() #include <cmath> // fabs()
#include <stdio.h> // sprintf() #include <cstdio> // sprintf()
#include <cstdlib> // atoi()
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>

View file

@ -37,6 +37,8 @@ HISTORY
INCLUDES INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <cstring>
#include "FGfdmSocket.h" #include "FGfdmSocket.h"
namespace JSBSim { namespace JSBSim {
@ -79,7 +81,7 @@ FGfdmSocket::FGfdmSocket(string address, int port)
memset(&scktName, 0, sizeof(struct sockaddr_in)); memset(&scktName, 0, sizeof(struct sockaddr_in));
scktName.sin_family = AF_INET; scktName.sin_family = AF_INET;
scktName.sin_port = htons(port); 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); int len = sizeof(struct sockaddr_in);
if (connect(sckt, (struct sockaddr*)&scktName, len) == 0) { // successful if (connect(sckt, (struct sockaddr*)&scktName, len) == 0) { // successful
cout << "Successfully connected to socket for output ..." << endl; cout << "Successfully connected to socket for output ..." << endl;
@ -113,7 +115,7 @@ FGfdmSocket::FGfdmSocket(int port)
sckt = socket(AF_INET, SOCK_STREAM, 0); sckt = socket(AF_INET, SOCK_STREAM, 0);
if (sckt >= 0) { // successful 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_family = AF_INET;
scktName.sin_port = htons(port); scktName.sin_port = htons(port);
int len = sizeof(struct sockaddr_in); int len = sizeof(struct sockaddr_in);

View file

@ -417,7 +417,7 @@ float Airplane::getTailIncidence()
return _tailIncidence; return _tailIncidence;
} }
char* Airplane::getFailureMsg() const char* Airplane::getFailureMsg()
{ {
return _failureMsg; return _failureMsg;
} }

View file

@ -90,7 +90,7 @@ public:
float getCruiseAoA(); float getCruiseAoA();
float getTailIncidence(); float getTailIncidence();
float getApproachElevator() { return _approachElevator.val; } float getApproachElevator() { return _approachElevator.val; }
char* getFailureMsg(); const char* getFailureMsg();
static void setupState(float aoa, float speed, float gla, State* s); // utility static void setupState(float aoa, float speed, float gla, State* s); // utility
@ -172,7 +172,7 @@ private:
float _cruiseAoA; float _cruiseAoA;
float _tailIncidence; float _tailIncidence;
Control _approachElevator; Control _approachElevator;
char* _failureMsg; const char* _failureMsg;
}; };
}; // namespace yasim }; // namespace yasim

View file

@ -1013,7 +1013,7 @@ char* FGFDM::dup(const char* s)
return s2; return s2;
} }
int FGFDM::attri(XMLAttributes* atts, char* attr) int FGFDM::attri(XMLAttributes* atts, const char* attr)
{ {
if(!atts->hasAttribute(attr)) { if(!atts->hasAttribute(attr)) {
SG_LOG(SG_FLIGHT,SG_ALERT,"Missing '" << 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); 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); const char* val = atts->getValue(attr);
if(val == 0) return def; if(val == 0) return def;
else return atol(val); else return atol(val);
} }
float FGFDM::attrf(XMLAttributes* atts, char* attr) float FGFDM::attrf(XMLAttributes* atts, const char* attr)
{ {
if(!atts->hasAttribute(attr)) { if(!atts->hasAttribute(attr)) {
SG_LOG(SG_FLIGHT,SG_ALERT,"Missing '" << 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); 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); const char* val = atts->getValue(attr);
if(val == 0) return def; if(val == 0) return def;
else return (float)atof(val); else return (float)atof(val);
} }
double FGFDM::attrd(XMLAttributes* atts, char* attr) double FGFDM::attrd(XMLAttributes* atts, const char* attr)
{ {
if(!atts->hasAttribute(attr)) { if(!atts->hasAttribute(attr)) {
SG_LOG(SG_FLIGHT,SG_ALERT,"Missing '" << 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); 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); const char* val = atts->getValue(attr);
if(val == 0) return def; 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 // Unfortunately, this usage creeped into existing configuration files
// while I wasn't active, and it's going to be hard to remove. Issue // 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... // 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); const char* val = atts->getValue(attr);
if(val == 0) return false; if(val == 0) return false;

View file

@ -49,13 +49,13 @@ private:
bool eq(const char* a, const char* b); bool eq(const char* a, const char* b);
bool caseeq(const char* a, const char* b); bool caseeq(const char* a, const char* b);
char* dup(const char* s); char* dup(const char* s);
int attri(XMLAttributes* atts, char* attr); int attri(XMLAttributes* atts, const char* attr);
int attri(XMLAttributes* atts, char* attr, int def); int attri(XMLAttributes* atts, const char* attr, int def);
float attrf(XMLAttributes* atts, char* attr); float attrf(XMLAttributes* atts, const char* attr);
float attrf(XMLAttributes* atts, char* attr, float def); float attrf(XMLAttributes* atts, const char* attr, float def);
double attrd(XMLAttributes* atts, char* attr); double attrd(XMLAttributes* atts, const char* attr);
double attrd(XMLAttributes* atts, char* attr, double def); double attrd(XMLAttributes* atts, const char* attr, double def);
bool attrb(XMLAttributes* atts, char* attr); bool attrb(XMLAttributes* atts, const char* attr);
// The core Airplane object we manage. // The core Airplane object we manage.
Airplane _airplane; Airplane _airplane;

View file

@ -1,5 +1,8 @@
#include <stdio.h> #include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <simgear/props/props.hxx> #include <simgear/props/props.hxx>
#include <simgear/xml/easyxml.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) { if(!a->getFailureMsg() && argc > 2 && strcmp(argv[2], "-g") == 0) {
float alt = 5000, kts = 100; float alt = 5000, kts = 100;
for(int i=3; i<argc; i++) { for(int i=3; i<argc; i++) {
if (strcmp(argv[i], "-a") == 0) alt = atof(argv[++i]); if (std::strcmp(argv[i], "-a") == 0) alt = std::atof(argv[++i]);
else if(strcmp(argv[i], "-s") == 0) kts = atof(argv[++i]); else if(std::strcmp(argv[i], "-s") == 0) kts = std::atof(argv[++i]);
else return usage(); else return usage();
} }
yasim_graph(a, alt, kts); yasim_graph(a, alt, kts);

View file

@ -67,17 +67,17 @@ extern void printScreen(puObject *);
extern void helpCb(puObject *); extern void helpCb(puObject *);
typedef struct { typedef struct {
char *name; const char *name;
void (*fn)(puObject *); void (*fn)(puObject *);
} __fg_gui_fn_t; } __fg_gui_fn_t;
extern const __fg_gui_fn_t __fg_gui_fn[]; extern const __fg_gui_fn_t __fg_gui_fn[];
// GLOBAL COMMON DIALOG BOX TEXT STRINGS // GLOBAL COMMON DIALOG BOX TEXT STRINGS
extern char *gui_msg_OK; // "OK" extern const char *gui_msg_OK; // "OK"
extern char *gui_msg_NO; // "NO" extern const char *gui_msg_NO; // "NO"
extern char *gui_msg_YES; // "YES" extern const char *gui_msg_YES; // "YES"
extern char *gui_msg_CANCEL; // "CANCEL" extern const char *gui_msg_CANCEL; // "CANCEL"
extern char *gui_msg_RESET; // "RESET" extern const char *gui_msg_RESET; // "RESET"
// mouse.cxx // mouse.cxx
extern void guiInitMouse(int width, int height); extern void guiInitMouse(int width, int height);

View file

@ -103,11 +103,11 @@ extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
// TODO: remove after the last hardcoded dialog has died // TODO: remove after the last hardcoded dialog has died
char *gui_msg_OK = "OK"; const char *gui_msg_OK = "OK";
char *gui_msg_NO = "NO"; const char *gui_msg_NO = "NO";
char *gui_msg_YES = "YES"; const char *gui_msg_YES = "YES";
char *gui_msg_CANCEL = "CANCEL"; const char *gui_msg_CANCEL = "CANCEL";
char *gui_msg_RESET = "RESET"; const char *gui_msg_RESET = "RESET";
const __fg_gui_fn_t __fg_gui_fn[] = { const __fg_gui_fn_t __fg_gui_fn[] = {

View file

@ -22,6 +22,8 @@
#include <math.h> #include <math.h>
#include <cstdlib>
#include <vector> #include <vector>
SG_USING_STD(vector); SG_USING_STD(vector);
@ -112,7 +114,7 @@ fgExit (int status)
#endif #endif
SG_LOG(SG_GENERAL, SG_INFO, "Exiting FlightGear with status " << status); SG_LOG(SG_GENERAL, SG_INFO, "Exiting FlightGear with status " << status);
exit(status); std::exit(status);
} }

View file

@ -1,3 +1,5 @@
#include <cstring>
#include "UGear_command.hxx" #include "UGear_command.hxx"
@ -18,7 +20,7 @@ static char calc_nmea_cksum(const char *sentence) {
// cout << sentence << endl; // cout << sentence << endl;
len = strlen(sentence); len = std::strlen(sentence);
sum = sentence[0]; sum = sentence[0];
for ( i = 1; i < len; i++ ) { for ( i = 1; i < len; i++ ) {
// cout << sentence[i]; // cout << sentence[i];