C++ ‘;标准::获取时间’;尚未申报

C++ ‘;标准::获取时间’;尚未申报,c++,c++11,datetime,gcc,time,C++,C++11,Datetime,Gcc,Time,我使用get_time()和mtkime()将DateTime类的一个对象的值转换为unix时间戳,以便轻松比较DateTime类的两个实例。这是我生成时间戳的代码 void DateTime::setTimeStamp() 服务器的编译器在查找mtkime时没有问题,以防信息有帮助 我的Mac编译器版本 配置有: --prefix=/Applications/Xcode.app/Contents/Developer/usr--with gxx include dir=/usr/include/

我使用get_time()和mtkime()将DateTime类的一个对象的值转换为unix时间戳,以便轻松比较DateTime类的两个实例。这是我生成时间戳的代码

void DateTime::setTimeStamp() 服务器的编译器在查找mtkime时没有问题,以防信息有帮助

我的Mac编译器版本 配置有: --prefix=/Applications/Xcode.app/Contents/Developer/usr--with gxx include dir=/usr/include/c++/4.2.1 Apple LLVM版本9.0.0(clang-900.0.37)目标:x86_64-Apple-darwin16.7.0线程模型:posix InstalledDir: /Applications/Xcode.app/Contents/Developer/toolschains/xcodefault.xctoolschain/usr/bin

服务器GNU编译器版本 gcc(gcc)5.3.1 20160406(红帽5.3.1-6)

我通过运行

gcc --version
DateTime.h
#包括
#包括
#包括
#包括
#包括
#包括
使用std::ostream;
使用std::istream;
使用std::string;
使用std::setfill;
使用std::setw;
使用std::endl;
使用std::stringstream;
使用std::istringstream;
使用std::cout;
使用std::无效的_参数;
使用std::exit;
使用std::get_time;
/*代码*/

通过在编译调用中添加“-std=c++11”,我能够在服务器上成功编译代码。这项工作:

g++ -std=c++11 DateTime.cpp

在您的许多配置选项中是否有一个
-std=c++11
?我是个新手。这是一个GCC编译器选项。您没有指定服务器如何调用它,但是您应该确保提供了该选项。谢谢
gcc --version
#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*/
g++ -std=c++11 DateTime.cpp