Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
February 07, 2007 What happened to _argptr ? | ||||
---|---|---|---|---|
| ||||
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? |
February 07, 2007 Re: What happened to _argptr ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomas Lindquist Olsen | == 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 |
February 07, 2007 Re: What happened to _argptr ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to jcc7 | 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 |
February 07, 2007 Re: What happened to _argptr ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomas Lindquist Olsen | 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
|
February 08, 2007 Re: What happened to _argptr ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bill Baxter | 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.
|
February 09, 2007 Re: What happened to _argptr ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomas Lindquist Olsen | 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.
|
February 09, 2007 Re: What happened to _argptr ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lionello Lunesu | Lionello Lunesu wrote:
>
> You need std.c.stdarg for C functions.
>
> L.
Not according to the spec.
|
Copyright © 1999-2021 by the D Language Foundation