L
Laurent Deniau
When I compile the code below with gcc -std=c99 -W -Wall -pedantic -O3
-Winline, it reports the following:
variadic.c: In function ‘fv’:
variadic.c:12: warning: function ‘fv’ can never be inlined because it
uses variable argument lists
variadic.c: In function ‘vf’:
variadic.c:12: warning: inlining failed in call to ‘fv’: function not
inlinable
variadic.c:27: warning: called from here
but the function does not use a variable argument lists, it uses a
variable of type va_list. Did I miss something or gcc emits an invalid
warning?
ld.
#include <stdarg.h>
#include <stdio.h>
static inline int f(int a, va_list va) {
return a + va_arg(va,int);
}
static inline int fv(int a, va_list va) {
int res;
va_list vac;
va_copy(vac, va);
res = f(a, vac);
va_end(vac);
return res;
}
static int vf(int a, ...) {
int ret;
va_list va;
va_start(va, a);
ret = fv(a, va);
va_end(va);
return ret;
}
int main(void) {
printf("%d\n", vf(1,2));
}
-Winline, it reports the following:
variadic.c: In function ‘fv’:
variadic.c:12: warning: function ‘fv’ can never be inlined because it
uses variable argument lists
variadic.c: In function ‘vf’:
variadic.c:12: warning: inlining failed in call to ‘fv’: function not
inlinable
variadic.c:27: warning: called from here
but the function does not use a variable argument lists, it uses a
variable of type va_list. Did I miss something or gcc emits an invalid
warning?
ld.
#include <stdarg.h>
#include <stdio.h>
static inline int f(int a, va_list va) {
return a + va_arg(va,int);
}
static inline int fv(int a, va_list va) {
int res;
va_list vac;
va_copy(vac, va);
res = f(a, vac);
va_end(vac);
return res;
}
static int vf(int a, ...) {
int ret;
va_list va;
va_start(va, a);
ret = fv(a, va);
va_end(va);
return ret;
}
int main(void) {
printf("%d\n", vf(1,2));
}