MSVC++ tweaks.

This commit is contained in:
curt 2001-05-15 22:17:58 +00:00
parent 6a481eed36
commit e5282caea5
3 changed files with 25 additions and 1 deletions

View File

@ -22,6 +22,10 @@
// $Id$ // $Id$
#ifdef HAVE_CONFIG_H
# include <simgear_config.h>
#endif
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <errno.h> // for errno #include <errno.h> // for errno
@ -184,6 +188,9 @@ static double sidereal_course( time_t cur_time, struct tm *gmt, double lng )
// Update the time related variables // Update the time related variables
void SGTime::update( double lon, double lat, long int warp ) { void SGTime::update( double lon, double lat, long int warp ) {
double gst_precise, gst_course; double gst_precise, gst_course;
#ifdef _MSC_VER
tm * gmt = &m_gmt;
#endif
SG_LOG( SG_EVENT, SG_DEBUG, "Updating time" ); SG_LOG( SG_EVENT, SG_DEBUG, "Updating time" );
@ -195,10 +202,14 @@ void SGTime::update( double lon, double lat, long int warp ) {
<< " warp = " << warp ); << " warp = " << warp );
// get GMT break down for current time // get GMT break down for current time
#ifdef _MSC_VER
memcpy( gmt, gmtime(&cur_time), sizeof(tm) );
#else
gmt = gmtime(&cur_time); gmt = gmtime(&cur_time);
#endif
SG_LOG( SG_EVENT, SG_DEBUG, SG_LOG( SG_EVENT, SG_DEBUG,
" Current GMT = " << gmt->tm_mon+1 << "/" " Current GMT = " << gmt->tm_mon+1 << "/"
<< gmt->tm_mday << "/" << gmt->tm_year << " " << gmt->tm_mday << "/" << (1900 + gmt->tm_year) << " "
<< gmt->tm_hour << ":" << gmt->tm_min << ":" << gmt->tm_hour << ":" << gmt->tm_min << ":"
<< gmt->tm_sec ); << gmt->tm_sec );

View File

@ -78,7 +78,11 @@ private:
time_t cur_time; time_t cur_time;
// Break down of equivalent GMT time // Break down of equivalent GMT time
#ifdef _MSC_VER
struct tm m_gmt; // copy of system gmtime(&time_t) structure
#else
struct tm *gmt; struct tm *gmt;
#endif
// offset of local time relative to GMT // offset of local time relative to GMT
time_t local_offset; time_t local_offset;
@ -162,7 +166,11 @@ public:
inline char* get_zonename() const { return zonename; } inline char* get_zonename() const { return zonename; }
/** @return GMT in a "brokent down" tm structure */ /** @return GMT in a "brokent down" tm structure */
#ifdef _MSC_VER
inline struct tm* getGmt()const { return (struct tm *)&m_gmt; };
#else
inline struct tm* getGmt()const { return gmt; }; inline struct tm* getGmt()const { return gmt; };
#endif
/** @return julian date */ /** @return julian date */
inline double getJD() const { return jd; }; inline double getJD() const { return jd; };

View File

@ -132,11 +132,16 @@ TimezoneContainer::TimezoneContainer(const char *filename)
if (feof(infile)) { if (feof(infile)) {
break; break;
} }
#ifdef _MSC_VER
if( buffer[0] == '#' )
continue;
#else
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
if (buffer[i] == '#') { if (buffer[i] == '#') {
buffer[i] = 0; buffer[i] = 0;
} }
} }
#endif
if (buffer[0]) { if (buffer[0]) {
data.push_back(new Timezone(buffer)); data.push_back(new Timezone(buffer));
} }