strptime给予"隐式声明"和"未定义的引用" [英] strptime giving "implicit declaration" and "undefined reference"

查看:1966
本文介绍了strptime给予"隐式声明"和"未定义的引用"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,当我使用功能 strptime 我就获得了警告:

So, when I use the function strptime I get both a warning:

warning: implicit declaration of function 'strptime'

和后一个错误:

undefined reference to 'strptime'

是的,我已经包括 time.h中。下面是我用它的小样本code。

Yes, I've included time.h. Here is a small sample code of me using it.

#include <time.h>

void my_function()
{
    char buf* = "2016-02-05 12:45:10";
    struct tm time*;
    ...
    strptime(buf, "%F %T", &time);
    ...
}

我知道 time.h中在同一个 .C 文件工作,因为,我使用的strftime time_t的'结构TM C> time.h中。我知道这是 strptime ,因为当我评论这行code的,它编译没有任何问题。

I know time.h is working because in the same .c file, I'm using strftime, time_t, and 'struct tm from time.h without a problem. I know it's strptime, because when I comment that line of code, it compiles without any problems.

推荐答案

您缺少告诉我们你是什么平台,你的编译器的版本,参数...

You are missing to tell us on what platform you are, your compiler version, arguments ...

在任何情况下, strptime 是不是在标准C,但配备POSIX。也许你有你的编译器选项错误,例如,它不为你提供POSIX扩展C.用gcc这将是使用 -std = gnu11 而不是 -std = C11 ,例如

In any case, strptime is not in standard C, but comes with POSIX. Probably you got your compiler options wrong such that it doesn't provide you with POSIX extensions to C. With gcc this would be to use -std=gnu11 instead of -std=c11, for example.

这篇关于strptime给予&QUOT;隐式声明&QUOT;和&QUOT;未定义的引用&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆