level 2
ylc19900623
楼主
初学UNIX编程。我想在apue.h中直接定义出错函数err_sys。我在apue.h中用了#include <error>
#include <stdarg.h>,
后面跟着
static void err_doit(int, int, const char *, va_list);
/*
* Nonfatal error related to a system call.
* Print a message and return.
*/
void
err_sys(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(1, errno, fmt, ap); va_end(ap);
exit(1);
};
但是使用的时候会出现如下错误
ylc@ubuntu:~$ gcc -o 1-2.out 1-2.c
/usr/include/apue.h:117: warning: ‘err_doit’ used but never defined
/tmp/ccgcflN9.o: In function `err_sys':
1-2.c:(.text+0x2e): undefined reference to `err_doit'
collect2: ld returned 1 exit status
求大神指导,指出我的错误。
2012年10月11日 10点10分
1
#include <stdarg.h>,
后面跟着
static void err_doit(int, int, const char *, va_list);
/*
* Nonfatal error related to a system call.
* Print a message and return.
*/
void
err_sys(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(1, errno, fmt, ap); va_end(ap);
exit(1);
};
但是使用的时候会出现如下错误
ylc@ubuntu:~$ gcc -o 1-2.out 1-2.c
/usr/include/apue.h:117: warning: ‘err_doit’ used but never defined
/tmp/ccgcflN9.o: In function `err_sys':
1-2.c:(.text+0x2e): undefined reference to `err_doit'
collect2: ld returned 1 exit status
求大神指导,指出我的错误。