www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - What happened to _argptr ?

reply Tomas Lindquist Olsen <tomas famolsen.dk> writes:
I'm trying to compile a pretty simple C-style variadic function.

extern(C)
void error(char* fmt, ...)
{
        vprintf(fmt, _argptr);
}

This gives the error:
Error: undefined identifier _argptr

According to http://digitalmars.com/d/function.html this should at least
compile.

Whats up?
Feb 07 2007
next sibling parent reply jcc7 <technocrat7 gmail.com> writes:
== Quote from Tomas Lindquist Olsen (tomas famolsen.dk)'s article
 I'm trying to compile a pretty simple C-style variadic function.
 extern(C)
 void error(char* fmt, ...)
 {
         vprintf(fmt, _argptr);
 }
 This gives the error:
 Error: undefined identifier _argptr
 According to http://digitalmars.com/d/function.html this should at least
 compile.
 Whats up?
I couldn't get your code to work either, but the following code seems to work (tested with DMD 1.0): import std.stdio; void foo(...) { writefln("\t%s", _argptr); } void main() { foo(1, 2, 3L, 4.5, 7F, "my str"); } A longer example is at: http://www.dsource.org/projects/tutorials/wiki/VariableArgumentsUsingStdStdargExample
Feb 07 2007
parent Tomas Lindquist Olsen <tomas famolsen.dk> writes:
jcc7 wrote:

 == Quote from Tomas Lindquist Olsen (tomas famolsen.dk)'s article
 I'm trying to compile a pretty simple C-style variadic function.
 extern(C)
 void error(char* fmt, ...)
 {
         vprintf(fmt, _argptr);
 }
 This gives the error:
 Error: undefined identifier _argptr
 According to http://digitalmars.com/d/function.html this should at least
 compile.
 Whats up?
I couldn't get your code to work either, but the following code seems to work (tested with DMD 1.0): import std.stdio; void foo(...) { writefln("\t%s", _argptr); } void main() { foo(1, 2, 3L, 4.5, 7F, "my str"); } A longer example is at:
http://www.dsource.org/projects/tutorials/wiki/VariableArgumentsUsingStdStdargExample This is clearly a bug, so I filed it: http://d.puremagic.com/issues/show_bug.cgi?id=937
Feb 07 2007
prev sibling next sibling parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Tomas Lindquist Olsen wrote:
 I'm trying to compile a pretty simple C-style variadic function.
 
 extern(C)
 void error(char* fmt, ...)
 {
         vprintf(fmt, _argptr);
 }
 
 This gives the error:
 Error: undefined identifier _argptr
 
 According to http://digitalmars.com/d/function.html this should at least
 compile.
 
 Whats up?
<rant mode="feel free to ignore> Ugh, I wish _argptr/_arguments would go away completely. There has to be a better way to handle variable numbers of arguments ... oh wait! there is! You specify a *name* for the argument list, kinda like how the other variadic arguments work in D, the ones for templates. _argptr/_arguments just look like a quick hack. By far the most hackish looking thing in all of D. </rant> --bb
Feb 07 2007
parent Tomas Lindquist Olsen <tomas famolsen.dk> writes:
Bill Baxter wrote:
 
 _argptr/_arguments just look like a quick hack.  By far the most hackish
 looking thing in all of D.
 </rant>
 
 --bb
I agree. It would still be nice if it worked according to spec though.
Feb 07 2007
prev sibling parent reply Lionello Lunesu <lio lunesu.remove.com> writes:
Tomas Lindquist Olsen wrote:
 I'm trying to compile a pretty simple C-style variadic function.
 
 extern(C)
 void error(char* fmt, ...)
 {
         vprintf(fmt, _argptr);
 }
 
 This gives the error:
 Error: undefined identifier _argptr
 
 According to http://digitalmars.com/d/function.html this should at least
 compile.
 
 Whats up?
You need std.c.stdarg for C functions. L.
Feb 09 2007
parent Tomas Lindquist Olsen <tomas famolsen.dk> writes:
Lionello Lunesu wrote:
 You need std.c.stdarg for C functions.
 
 L.
Not according to the spec.
Feb 09 2007