gpt4 book ai didi

c++ - Boost Date_Time问题编译一个简单的程序

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:59:22 25 4
gpt4 key购买 nike

我正在使用 Boost Date_Time 库编写一个非常愚蠢的程序。

int main(int srgc, char** argv) {
using namespace boost::posix_time;
date d(2002,Feb,1); //an arbitrary date
ptime t1(d, hours(5)+nanosec(100)); //date + time of day offset
ptime t2 = t1 - minutes(4)+seconds(2);
ptime now = second_clock::local_time(); //use the clock
date today = now.date(); //Get the date part out of the time
}

我无法编译它,编译器无法识别类型...好吧,我使用了 Boost 库的许多功能,比如序列化等等......我正确地构建了它们,并且在我的/usr/local/lib 文件夹中我可以看到 libboost_date_time.so 在那里(一个好兆头,这意味着我能够构建那个库)

当我编译时,我写了以下内容:

g++ -lboost_date_time main.cpp

但是当我指定 lib 时它显示的错误与我没有指定任何 lib 的错误相同。

这是什么?有人知道吗?

错误是

main.cpp: In function ‘int main(int, char**)’: main.cpp:9: error: ‘date’ was not declared in this scope main.cpp:9: error: expected ‘;’ before ‘d’ main.cpp:10: error: ‘d’ was not declared in this scope main.cpp:10: error: ‘nanosec’ was not declared in this scope main.cpp:13: error: expected ‘;’ before ‘today’

最佳答案

虽然我无法弄清楚你的代码中的 ss 是什么,如下限定 dateFeb 将使您的代码有效。

boost::gregorian::date
boost::date_time::Feb

希望这对您有所帮助。

关于c++ - Boost Date_Time问题编译一个简单的程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4711743/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com