- 论坛徽章:
- 0
|
在ldd3中的源码包里面,有一个改变console_loglevel的程序,为什么编译通不过呢?
- 1
- 2 #include <stdio.h>
- 3 #include <stdlib.h>
- 4 #include <string.h>
- 5#include <errno.h>
- 6 #define __LIBRARY__ /* _syscall3 and friends are only available through this */
- 27 #include <linux/unistd.h>
- 28
- 29 /* define the system call, to override the library function */
- 30 _syscall3(int, syslog, int, type, char *, bufp, int, len);
- 31
- 32 int main(int argc, char **argv)
- 33 {
- 34 int level;
- 35
- 36 if (argc==2) {
- 37 level = atoi(argv[1]); /* the chosen console */
- 38 } else {
- 39 fprintf(stderr, "%s: need a single arg\n",argv[0]); exit(1);
- 40 }
- 41 if (syslog(8,NULL,level) < 0) {
- 42 fprintf(stderr,"%s: syslog(setlevel): %s\n",
- 43 argv[0],strerror(errno));
- 44 exit(1);
- 45 }
- 46 exit(0);
- 47 }
复制代码
gcc setlevel.后,错误如下:
setlevel.c:30: error: expected declaration specifiers or ‘...’ before ‘syslog’
setlevel.c:30: error: expected declaration specifiers or ‘...’ before ‘type’
setlevel.c:30: error: expected declaration specifiers or ‘...’ before ‘bufp’
setlevel.c:30: error: expected declaration specifiers or ‘...’ before ‘len’
setlevel.c:30: warning: data definition has no type or storage class |
|