D.gnu - va_start
- nix <nix_member pathlink.com> Nov 24 2004
- David Friedman <d3rdclsmail_a t_earthlink_d.t_net> Nov 24 2004
- Manfred Hansen <manfred toppoint.de> Nov 24 2004
Hello,
this programm compile successfully with dmd but with
gdc i get the following error message:
v_args1.d:6: template instance va_start!(char[]) va_start is not a template
declaration, it is a function
v_args1.d:6: function expected before (), not 'void'
import std.c.stdarg;
int foo(char[] x, ...) {
va_list ap;
va_start!(typeof(x))(ap, x);
printf("&x = %p, ap = %p\n", &x, ap);
printf("%.*s\n",x);
int i;
i = va_arg!(typeof(i))(ap);
printf("i = %d\n", i);
va_end(ap);
return i;
}
int main() {
int j;
j = foo("hello", 3);
printf("j = %d\n", j);
return 0;
}
Nov 24 2004
nix wrote:Hello, this programm compile successfully with dmd but with gdc i get the following error message: v_args1.d:6: template instance va_start!(char[]) va_start is not a template declaration, it is a function v_args1.d:6: function expected before (), not 'void' import std.c.stdarg; int foo(char[] x, ...) { va_list ap; va_start!(typeof(x))(ap, x); printf("&x = %p, ap = %p\n", &x, ap); printf("%.*s\n",x); int i; i = va_arg!(typeof(i))(ap); printf("i = %d\n", i); va_end(ap); return i; } int main() { int j; j = foo("hello", 3); printf("j = %d\n", j); return 0; }
Argh, I didn't implement va_start correctly. As a workaround, you can use "va_start(ap,x);" Is foo supposed to be an "extern(C)" function? If not, you can use the predefined variable "_argptr" and there is no need to call va_start. David
Nov 24 2004
Thank you for the quick answer Manfred David Friedman wrote:nix wrote:Hello, this programm compile successfully with dmd but with gdc i get the following error message: v_args1.d:6: template instance va_start!(char[]) va_start is not a template declaration, it is a function v_args1.d:6: function expected before (), not 'void' import std.c.stdarg; int foo(char[] x, ...) { va_list ap; va_start!(typeof(x))(ap, x); printf("&x = %p, ap = %p\n", &x, ap); printf("%.*s\n",x); int i; i = va_arg!(typeof(i))(ap); printf("i = %d\n", i); va_end(ap); return i; } int main() { int j; j = foo("hello", 3); printf("j = %d\n", j); return 0; }
Argh, I didn't implement va_start correctly. As a workaround, you can use "va_start(ap,x);" Is foo supposed to be an "extern(C)" function? If not, you can use the predefined variable "_argptr" and there is no need to call va_start. David
Nov 24 2004








Manfred Hansen <manfred toppoint.de>