www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Passing variadic arguments to C

reply "Foo" <Foo test.de> writes:
Is this possible?

Example:
----
void foo(Args...)(auto ref Args args) {
     sprintf(str.ptr, fmt.ptr, args);
}
----
Feb 22 2015
parent reply "anonymous" <anonymous example.com> writes:
On Sunday, 22 February 2015 at 17:09:27 UTC, Foo wrote:
 Is this possible?

 Example:
 ----
 void foo(Args...)(auto ref Args args) {
     sprintf(str.ptr, fmt.ptr, args);
 }
 ----
yes
Feb 22 2015
parent reply "Foo" <Foo test.de> writes:
On Sunday, 22 February 2015 at 17:15:06 UTC, anonymous wrote:
 On Sunday, 22 February 2015 at 17:09:27 UTC, Foo wrote:
 Is this possible?

 Example:
 ----
 void foo(Args...)(auto ref Args args) {
    sprintf(str.ptr, fmt.ptr, args);
 }
 ----
yes
I get the error, that I cannot pass a dynamic array to a C function.
Feb 22 2015
parent "Foo" <Foo test.de> writes:
On Sunday, 22 February 2015 at 17:20:23 UTC, Foo wrote:
 On Sunday, 22 February 2015 at 17:15:06 UTC, anonymous wrote:
 On Sunday, 22 February 2015 at 17:09:27 UTC, Foo wrote:
 Is this possible?

 Example:
 ----
 void foo(Args...)(auto ref Args args) {
   sprintf(str.ptr, fmt.ptr, args);
 }
 ----
yes
I get the error, that I cannot pass a dynamic array to a C function.
My fault, the reason was that Args contains strings. ;)
Feb 22 2015