我基于另一个GNU项目开始了我的第一个GNU项目,以对其进行改进并更改实现。
我尝试实现自己的构建方法,但是与时间和时钟相关的功能破坏了我的构建。
我读了很多关于堆栈溢出的问题,但我很困惑的三个库chrono,ctime和time.h。
这是构建错误:
/src/gamed/Logger.cpp
#include "Logger.h"
#include <errno.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>
const std::string Logger::CurrentDateTime()
{
time_t now = time(0);
struct tm tstruct;
char buf[80];
tstruct = *localtime(&now);
strftime(buf, sizeof(buf), "%Y-%m-%d %X", &tstruct);
return buf;
}
Run Code Online (Sandbox Code Playgroud)
错误:找不到时间,本地时间和strftime标识符
/src/gamed/Packets.h
#ifndef _PACKETS_H
#define _PACKETS_H
#include <time.h>
#include <cmath>
#include <set>
{...}
class GamePacket : public BasePacket {
public:
GamePacket(uint8 cmd = 0, uint32 netId = 0) : BasePacket(cmd, netId) …Run Code Online (Sandbox Code Playgroud)