digitalmars.D - What happened to _argptr ?
- Tomas Lindquist Olsen (11/11) Feb 07 2007 I'm trying to compile a pretty simple C-style variadic function.
- jcc7 (14/25) Feb 07 2007 I couldn't get your code to work either, but the following code seems to...
- Tomas Lindquist Olsen (4/35) Feb 07 2007 http://www.dsource.org/projects/tutorials/wiki/VariableArgumentsUsingStd...
- 
Bill Baxter
 (10/25)
 Feb 07 2007
 Tomas Lindquist Olsen (3/9) Feb 07 2007 I agree. 
- Lionello Lunesu (3/18) Feb 09 2007 You need std.c.stdarg for C functions.
- Tomas Lindquist Olsen (2/5) Feb 09 2007 Not according to the spec.
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 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
jcc7 wrote:== Quote from Tomas Lindquist Olsen (tomas famolsen.dk)'s articlehttp://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=937I'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:
 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> --bbI 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>
 Tomas Lindquist Olsen <tomas famolsen.dk> 