gpt4 book ai didi

c - 为什么 gmtime() 函数返回 NULL?

转载 作者:太空宇宙 更新时间:2023-11-04 03:31:13 35 4
gpt4 key购买 nike

我正在尝试使用 epoch 时间在 STM32L051T6 微 Controller 上设置 RTC 时间。下面是我的代码。

void Rtc_SetTime(uint32_t time_)
{
struct tm* brokenTime;
const time_t temp = 3600;

brokenTime = gmtime(&temp);

if (NULL == brokenTime)
{
printf("Error: Failed to convert time.\r\n");
}
}

当我调用上面的函数时。它总是转到 if 语句并打印错误。我尝试将值 3600、1459841178 作为参数传递。全部失败。代码有什么问题?

最佳答案

我在这里找到了以下内容: http://support.raisonance.com/content/gmtime-and-localtime-broken-arm-gcc-lib

所以它可能不会实现......

I think gmtime and localtime is broken in arm-gcc lib for STM32F10x.

I have try it in keil uVision and working fine there(localtime anyway, gmtime not implemented in keil). gmtime and localtime is searching for _sbrk when linking.

"sbrkr.c: (.text+0xc): undefined reference to `_sbrk'"

关于c - 为什么 gmtime() 函数返回 NULL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36419785/

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