尚未声明“ std :: get_time”
‘std::get_time’ has not been declared
我正在使用get_time()和mtkime()将datetime类的对象值转换为unix时间戳,以便我可以轻松地比较我的datetime类的两个实例。这是我生成时间戳的代码
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 );
此代码编译并完美地在我的Mac上工作。但是,在远程服务器上编译时,它是唯一的错误。
DateTime.h:40:12: error: ‘std::get_time’ has not been declared
using std::get_time;
服务器的编译器在信息有帮助时找到MTKIME没有问题。
我的Mac编译器版本
配置为: -prefix =/applications/xcode.app/cottents/developer/usr -with-gxx-include-dir =/usr/includs/cruppe/c /4.2.1 apple llvm版本9.0.0.0.0.0(clang-900.0.37)target:x86_64- apple-darwin16.7.0线程模型:posix 安装Dir: /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin
服务器GNU编译器版本
GCC(GCC)5.3.1 20160406(Red Hat 5.3.1-6)
我通过运行
在我的Mac和远程服务器上获得了编译器的版本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*/
我能够通过将" -std = c 11"添加到我的编译呼叫中,成功地在服务器上编译了我的代码。这有效:
g++ -std=c++11 DateTime.cpp
相关文章:
- Cpp-Tuple使用带有变量的get
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 通过 get-Method 访问变量在类外不起作用
- 为什么无论你输入什么,这"while(cin.get(str,3))"只运行一次?
- Boost.Asio/OpenSSL HTTPS GET certificate trouble
- C++中是否有任何函数等同于python中字典的get函数?
- 使用istringstearm和get行缓慢读取文件
- 如何将 c++ get 函数代码转换为 opencv 算法中使用的 python
- 为什么我会收到"Run-Time Check Failure #2 - Stack around the variable 'pr' was corrupted"错误?
- 使用 cin.get() 初始化字符数组
- std::variant<>::get() 不能使用 Apple LLVM 10.0 编译
- 编写 cin.get() 以接收字符数组时出现问题
- 作用域枚举和标准::get
- Visual Studio 2017 中的 cpprestapi 问题找不到 POST/GET 常量
- 在 C++/C 中使用 CURL 发出带有数据文件的 GET HTTP 请求
- 解析某些行的文本和输出"time of appearance"
- 使用"push_back"作为带有"get"函数C++的向量
- 使用 cin.get 读取字符数组
- 如何使用 fstream 的 .get 字符串?
- c++ get millsecond time