The code below should explain the problem sufficiently: ------------------------------------------------------- module vararg; // Works void a(...) { void* v = _argptr; } // Works void b(char* fmt, ...) { void* v = _argptr; } // Error: variadic functions with non-D linkage must have at least one parameter // which is correct extern(C) void c(...) { void* v = _argptr; } // Error: undefined identifier _argptr // vararg.d(22): Error: cannot implicitly convert expression (_argptr) of type int to void* // this is contrary to spec! extern(C) void d(char* fmt, ...) { void* v = _argptr; } void main() { a("a", 2, 3.0); b("b", 2, 3.0); c("c", 3, 3.0); d("c", 3, 3.0); }
I don't think this is a bug. For extern(C) you need std.c.stdarg, va_start..va_end..
According to the spec the _argptr variable should be available... So it most definitely is!
While working on GDC, it was found this bug still exists in 1.063. The problem appears to be an if statement in func.c around line 811. "parameters" is not initialized until further down in the function. By substituting "f->parameters" the problem is resolved. ----------------------------------------------------------- // Original if statement if (f->linkage == LINKd || (parameters && parameters->dim)) // Modified if statement if (f->linkage == LINKd || (f->parameters && Parameter::dim(f->parameters))) GDC ticket. http://bitbucket.org/goshawk/gdc/issue/57/c-style-variadic-functions-broken
https://github.com/D-Programming-Language/dmd/commit/888bd52ab4d07c132c38f231dfabea648bf94cba https://github.com/D-Programming-Language/dmd/commit/8d2bf812530f51b40fe08c9b0f526b60575ae604
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル