小编Ahr*_*Dev的帖子

无法使用与时间和时钟相关的函数进行编译C ++

我基于另一个GNU项目开始了我的第一个GNU项目,以对其进行改进并更改实现。

我尝试实现自己的构建方法,但是与时间和时钟相关的功能破坏了我的构建。

我读了很多关于堆栈溢出的问题,但我很困惑的三个库chronoctimetime.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)

c++ time build clock

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

build ×1

c++ ×1

clock ×1

time ×1