digitalmars.D - What happened to _argptr ?
- Tomas Lindquist Olsen <tomas famolsen.dk> Feb 07 2007
- jcc7 <technocrat7 gmail.com> Feb 07 2007
- Tomas Lindquist Olsen <tomas famolsen.dk> Feb 07 2007
- Bill Baxter <dnewsgroup billbaxter.com> Feb 07 2007
- Tomas Lindquist Olsen <tomas famolsen.dk> Feb 07 2007
- Lionello Lunesu <lio lunesu.remove.com> Feb 09 2007
- Tomas Lindquist Olsen <tomas famolsen.dk> Feb 09 2007
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
== Quote from Tomas Lindquist Olsen (tomas famolsen.dk)'s articleI'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
jcc7 wrote:== Quote from Tomas Lindquist Olsen (tomas famolsen.dk)'s articleI'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:
This is clearly a bug, so I filed it: http://d.puremagic.com/issues/show_bug.cgi?id=937
Feb 07 2007
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
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
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
Lionello Lunesu wrote:You need std.c.stdarg for C functions. L.
Not according to the spec.
Feb 09 2007









Tomas Lindquist Olsen <tomas famolsen.dk> 