当前位置: 技术问答>linux和unix
gcc 编译一问
来源: 互联网 发布时间:2015-11-04
本文导语: 我的gcc编译的时候出现如下错误, temp]gcc -g -o famodl famodl.c -lnsl -lsocket In file included from famodl.c:14: /usr/local/lib/gcc-lib/sparc-sun-solaris2.9/3.3.2/include/varargs.h:4:2: #error "GCC no longer implements ." /usr/local/lib/gcc-lib/sparc-sun-...
我的gcc编译的时候出现如下错误,
temp]gcc -g -o famodl famodl.c -lnsl -lsocket
In file included from famodl.c:14:
/usr/local/lib/gcc-lib/sparc-sun-solaris2.9/3.3.2/include/varargs.h:4:2: #error "GCC no longer implements ."
/usr/local/lib/gcc-lib/sparc-sun-solaris2.9/3.3.2/include/varargs.h:5:2: #error "Revise your code to use ."
用cc编译可以通过,如何clear上面的编译错误?
temp]gcc -g -o famodl famodl.c -lnsl -lsocket
In file included from famodl.c:14:
/usr/local/lib/gcc-lib/sparc-sun-solaris2.9/3.3.2/include/varargs.h:4:2: #error "GCC no longer implements ."
/usr/local/lib/gcc-lib/sparc-sun-solaris2.9/3.3.2/include/varargs.h:5:2: #error "Revise your code to use ."
用cc编译可以通过,如何clear上面的编译错误?
|
varargs是过时的用法,新的gcc版本不再支持,这是varargs的代码:
#include
#define MAXARGS 100
/* execl is called by
* execl(file, arg1, arg2, ..., (char *)0);
*/
execl(va_alist)
va_dcl
{
va_list ap;
char *file;
char *args[MAXARGS];
int argno = 0;
va_start(ap);
file = va_arg(ap, char *);
while ((args[argno++] = va_arg(ap, char *)) != (char *)0)
;
va_end(ap);
return execv(file, args);
}
将包含的头文件varargs.h用stdarg.h代替, 像这样:
#include
#define MAXARGS 31
/*
* execl is called by
* execl(file, arg1, arg2, ..., (char *)(0));
*/
int execl (const char *file, const char *args, ...)
{
va_list ap;
char *array[MAXARGS];
int argno = 0;
va_start(ap, args);
while (args != 0) {
array[argno++] = args;
args = va_arg(ap, const char *);
}
va_end(ap);
return execv(file, array);
}
#include
#define MAXARGS 100
/* execl is called by
* execl(file, arg1, arg2, ..., (char *)0);
*/
execl(va_alist)
va_dcl
{
va_list ap;
char *file;
char *args[MAXARGS];
int argno = 0;
va_start(ap);
file = va_arg(ap, char *);
while ((args[argno++] = va_arg(ap, char *)) != (char *)0)
;
va_end(ap);
return execv(file, args);
}
将包含的头文件varargs.h用stdarg.h代替, 像这样:
#include
#define MAXARGS 31
/*
* execl is called by
* execl(file, arg1, arg2, ..., (char *)(0));
*/
int execl (const char *file, const char *args, ...)
{
va_list ap;
char *array[MAXARGS];
int argno = 0;
va_start(ap, args);
while (args != 0) {
array[argno++] = args;
args = va_arg(ap, const char *);
}
va_end(ap);
return execv(file, array);
}