mercredi 27 septembre 2017

‘get_time’ is not a member of ‘std' and ‘std::get_time’ has not been declared

I am using get_time() and mtkime() to convert the values of an object of my DateTime class to a unix timestamp so that I can easily compare two instances of my DateTime class. Here is my code for generating the time stamp

void DateTime::setTimeStamp()

stringstream date_ss1;
date_ss1 << (*this);
istringstream date_iss(date_ss1.str());
struct tm date;
date_iss >> get_time( &date, "%Y/%m/%d-%H:%M" );
timestamp = mktime( &date );

This code compiles and works perfectly on my Mac. BUT it gives this as the only error when compiling it on a remote server.

DateTime.h:40:12: error: ‘std::get_time’ has not been declared
 using std::get_time;

The server's compiler has no problem finding mtkime in case that info is of help.

My Mac compiler version

Configured with: --prefix=/Applications/http://ift.tt/1d5DwEL --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 9.0.0 (clang-900.0.37) Target: x86_64-apple-darwin16.7.0 Thread model: posix InstalledDir: /Applications/http://ift.tt/1z8WHIF

Server GNU compiler version

gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)

I got the version of the compilers on both my Mac and the remote server by running

gcc --version

DateTime.h

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <sstream>
#include <ctime>
#include <exception>    

using std::ostream;
using std::istream;
using std::string;
using std::setfill;
using std::setw;
using std::endl;
using std::stringstream;
using std::istringstream;
using std::cout;
using std::invalid_argument;
using std::exit;
using std::get_time;

/*code*/

Please let me know if you need me to include more info to get to the bottom of this. Appreciate your help!

Aucun commentaire:

Enregistrer un commentaire