static arrays in C functions

Lutger lutger.blijdestijn at gmail.com
Tue Dec 8 02:08:15 PST 2009


Since a while some extern(C) functions which take arrays seem to be broken. 
Can anybody clarify /confirm how they should be declared? 

For example I stumbled upon this:

import core.sys.posix.unistd, std.stdio;

void main()
{
    int[2] fd;
    writeln( pipe(fd) ); // failes with errno == EFAULT
}

In core.sys.posix.unistd, pipe is declared as: int pipe(int[2]);


This works though:

extern (C) { int pipe(int*); }

void main()
{
    int[2] fd;
    writeln( pipe(fd.ptr) ); 
}




More information about the Digitalmars-d-learn mailing list