QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1146|回复: 0

redhat9下如何使用timer

[复制链接]
发表于 2004-10-10 08:13:00 | 显示全部楼层 |阅读模式
[code:1]#include <stdio.h>
#include <stdlib.h>
#include <linux/timer.h>
void showint(unsigned long i)
{
       printf("%c",'.');
}

int main(void)
{
       timer_t *tl = (timer_t*)malloc(sizeof(timer_t));
       init_timer(tl);
       tl->expires = 100;
       tl->function = showint;
        add_timer(tl);
       return 0;
}

Makefile 文件:
TARGETFILE = mytest
SRC = mytest.cpp
CC = g++
CCOPT = -g
INCLS = -I.
LIBS =
DEFS =
CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
all:
       $(CC) $(CFLAGS) $(SRC) -o $(TARGETFILE) $(LIBS)
clean:
       rm -f *.o $(TARGETFILE) *.bak

错误信息
g++ -g -I.  mytest.cpp -o mytest
In file included from mytest.cpp:7:
/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:104: previous declaration as `typedef __timer_t timer_t'
/usr/include/linux/timer.h:45: 'spinlock_t' is used as a type, but is not
  defined as a type.
/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'
make: *** [all] Error 1

[/code:1]

请大家帮忙看看,好像是与time.h的定义冲突造成的,但是我指定使用的是/linux/timer.h,怎么回事呢,如果用gcc,有同样的错误,谢谢大家了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-7 10:35 , Processed in 0.063817 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表