c - 使用 vlc 库示例时函数“睡眠”的隐式声明
问题描述
我正在测试 vlc 库,以便能够制作 mp3 播放器。我找到了这个例子:
#include <stdio.h>
#include <stdlib.h>
#include <vlc/vlc.h>
int main(int argc, char* argv[])
{
libvlc_instance_t * inst;
libvlc_media_player_t *mp;
libvlc_media_t *m;
/* Load the VLC engine */
inst = libvlc_new (0, NULL);
/* Create a new item */
m = libvlc_media_new_location (inst, "http://mycool.movie.com/test.mov");
//m = libvlc_media_new_path (inst, "/path/to/test.mov");
/* Create a media player playing environement */
mp = libvlc_media_player_new_from_media (m);
/* No need to keep the media now */
libvlc_media_release (m);
#if 0
/* This is a non working code that show how to hooks into a window,
* if we have a window around */
libvlc_media_player_set_xwindow (mp, xid);
/* or on windows */
libvlc_media_player_set_hwnd (mp, hwnd);
/* or on mac os */
libvlc_media_player_set_nsobject (mp, view);
#endif
/* play the media_player */
libvlc_media_player_play (mp);
sleep (10); /* Let it play a bit */
/* Stop playing */
libvlc_media_player_stop (mp);
/* Free the media_player */
libvlc_media_player_release (mp);
libvlc_release (inst);
return 0;
}
我在编译时遇到的问题如下:
test.c: In function ‘main’:
test.c:37:6: warning: implicit declaration of function ‘sleep’ [-Wimplicit-function-declaration]
37 | sleep (10); /* Let it play a bit */
我尝试包含 time.h 库,但问题没有解决。有谁知道会发生什么?如果您可以向我推荐一些东西或者您有一些信息,vlclib 示例将不胜感激。或者如果您推荐任何其他书店,它也对我有用。谢谢
解决方案
POSIX sleep在header中声明unistd.h
,您需要包含它。
推荐阅读
- angular - 使用“forRoot”将配置数据传递给角度库的依赖项
- php - 如何在 Laravel 中将带有访问器的属性正确设置到模型中?
- javascript - material-ui输入选择属性隐藏body溢出-y滚动-react js
- apache - 当url包含特殊字符时如何重定向错误页面?
- python - 连接具有不同索引的数据帧
- angularjs - 如何在 Angular 指令中隐藏要在 DOM 中看到的属性?
- javascript - 如何重复执行一个命令并在抛出错误时执行另一个命令而不总是检查 if 条件?
- python - 用于老挝语分词和 PoS 标记的 LSTM Keras 实现
- python - Django rest框架,从其他模型数组创建模型
- android - 如何在 Kotlin 中使用 ViewModelProviders