当前位置: 技术问答>linux和unix
设置定时器,运行一个函数,为什么不能通过编译
来源: 互联网 发布时间:2015-06-27
本文导语: #include #include void function(unsigned long) { printf("timer... ChkGk()n"); } int init_timer_ChkGk(void) { struct timer_list timer_fs; init_timer(&timer_fs); timer_fs.expires = 500; //定时器定时50秒 timer_fs.data = (u...
#include
#include
void function(unsigned long)
{
printf("timer... ChkGk()n");
}
int init_timer_ChkGk(void)
{
struct timer_list timer_fs;
init_timer(&timer_fs);
timer_fs.expires = 500; //定时器定时50秒
timer_fs.data = (unsigned long)100;
timer_fs.function = function;
printf("timer function is started upn");
return 0;
}
编译错误信息:
In file included from /usr/include/linux/timer.h:18,
/usr/include/linux/spinlock.h:131: `atomic_t' was not declared in this
scope
/usr/include/linux/spinlock.h:131: `atomic' was not declared in this
scope
/usr/include/linux/spinlock.h:131: parse error before `*'
In file included from checkgk.cc:8:
/usr/include/linux/timer.h:32: field `vec' has incomplete type
/usr/include/linux/timer.h:37: field `vec' has incomplete type
/usr/include/linux/timer.h:42: conflicting types for `typedef struct
timer_list timer_t'
/usr/include/time.h:94: previous declaration as `typedef __timer_t
timer_t'
/usr/include/linux/timer.h:63: field `list' has incomplete type
/usr/include/linux/timer.h: In function `void init_timer (timer_list
*)':
/usr/include/linux/timer.h:105: `struct timer_list' has no member named
`list'
/usr/include/linux/timer.h:105: `struct timer_list' has no member named
`list'
/usr/include/linux/timer.h: In function `int timer_pending (const
timer_list *)':
/usr/include/linux/timer.h:121: `struct timer_list' has no member named
`list'
#include
void function(unsigned long)
{
printf("timer... ChkGk()n");
}
int init_timer_ChkGk(void)
{
struct timer_list timer_fs;
init_timer(&timer_fs);
timer_fs.expires = 500; //定时器定时50秒
timer_fs.data = (unsigned long)100;
timer_fs.function = function;
printf("timer function is started upn");
return 0;
}
编译错误信息:
In file included from /usr/include/linux/timer.h:18,
/usr/include/linux/spinlock.h:131: `atomic_t' was not declared in this
scope
/usr/include/linux/spinlock.h:131: `atomic' was not declared in this
scope
/usr/include/linux/spinlock.h:131: parse error before `*'
In file included from checkgk.cc:8:
/usr/include/linux/timer.h:32: field `vec' has incomplete type
/usr/include/linux/timer.h:37: field `vec' has incomplete type
/usr/include/linux/timer.h:42: conflicting types for `typedef struct
timer_list timer_t'
/usr/include/time.h:94: previous declaration as `typedef __timer_t
timer_t'
/usr/include/linux/timer.h:63: field `list' has incomplete type
/usr/include/linux/timer.h: In function `void init_timer (timer_list
*)':
/usr/include/linux/timer.h:105: `struct timer_list' has no member named
`list'
/usr/include/linux/timer.h:105: `struct timer_list' has no member named
`list'
/usr/include/linux/timer.h: In function `int timer_pending (const
timer_list *)':
/usr/include/linux/timer.h:121: `struct timer_list' has no member named
`list'
|
你使用的是内核头文件
|
看看你的编译命令
|
确定包含所有的头文件了吗?这些提示信息说明有未定义的成员