www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Template name in std.c.stdarg

The template va_start in this module seems to conflict with the function 
name within the same template:

<code>

/*
  * Placed in public domain.
  * Written by Hauke Duden and Walter Bright
  */

/* This is for use with extern(C) variable argument lists. */

module std.c.stdarg;

alias void* va_list;

template va_start(T)
{
     void va_start(out va_list ap, inout T parmn)
     {
	ap = cast(va_list)(cast(void*)&parmn + ((T.sizeof + int.sizeof - 1) & 
~(int.sizeof - 1)));
     }
}

</code>

When I attempt to declare an instance with:

	va_start!(wchar[]).va_start(vaArg, msg);

I get errors:

function std.c.stdarg.va_start!(wchar[]).va_start (void*,wchar[]) does 
not match argument types ()
Error: expected 2 arguments, not 0
no property 'va_start' for type 'void'
function expected before (), not 'int'

Now, When I change

	template va_start(T)
to:
	template _va_start(T)

and I declare it with:

	_va_start!(wchar[]).va_start(vaArg, msg);

It compiles and functions without error.

I think the problem comes from naming the template the same as a 
function defined within.
Apr 02 2005