Saaa Wrote:

> >
> > import std.stdarg;
> >
> > assert( _arguments[0] is typeid(int*) );
> > auto arg = va_arg!(int*)(_argptr);
> > *arg = 10;
> >
> > Probably.
> >
> >  -- Daniel
> 
> Calling the following returns an Access Violation Error after
> correctly writing the two lines.
> 
> void main()
> {
> int i;
> get( file, `i`, i);
> }
> 
> public void get(in char[][] file, in char[] identifier, ...)
> {
> assert( _arguments[0] is typeid(int) );
> writefln(`assert done`);
> auto arg = va_arg!(int*)(_argptr);
> writefln(`assign done`);
> *arg = 7;
> return;
> } 
> 
>

You get an AV because you're passing the argument by value. You need to pass 
its address instead.

Try this:

void main() {
  int i;
  get(file, "i", &i);
  writeln(i);
}

It will print "7".

Reply via email to