On Tue, Dec 8, 2009 at 2:08 AM, Lutger <lutger.blijdest...@gmail.com> wrote: > 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) ); > }
(Assuming you're talking about D2 here...) A few releases ago fixed-size arrays changed to be pass-by-value. But I guess there's still some logic in there to interpret int[2] as int* when inside an extern(C) block. It does seem like there's a bug there, though. I think pipe(fd) in the first case should fail to compile because it's attempting to pass by value where a pointer is expected. --bb