Re: Callbacks and interfacing with C

2012-10-30 Thread Jacob Carlborg
On 2012-10-30 18:44, Andrej Mitrovic wrote: All of them. void main() { pragma(msg, MyFn); pragma(msg, typeof(MyStruct.foo2)); pragma(msg, typeof(bar)); } extern (C) int function(int) extern (C) int function(int) extern (C) void(extern (C) int function(int) foo3) extern (C) int f

Re: Callbacks and interfacing with C

2012-10-30 Thread Andrej Mitrovic
On 10/30/12, Nick Sabalausky wrote: > Which, if any, of foo1/foo2/foo3 are extern(C)? (I know bar definitely > is.) All of them. void main() { pragma(msg, MyFn); pragma(msg, typeof(MyStruct.foo2)); pragma(msg, typeof(bar)); } extern (C) int function(int) extern (C) int function(int)

Re: Callbacks and interfacing with C

2012-10-30 Thread bearophile
Nick Sabalausky: Which, if any, of foo1/foo2/foo3 are extern(C)? (I know bar definitely is.) A general comment: if you are not sure of the answer, then the programmer that will read your code will probably have similar problems. So in such cases it's better to try to not write that code.

Re: Callbacks and interfacing with C

2012-10-30 Thread Nick Sabalausky
On Tue, 30 Oct 2012 11:15:55 +0100 Alex Rønne Petersen wrote: > On 30-10-2012 11:13, Nick Sabalausky wrote: > > Ok, a C function pointer like this: > > > > struct MyStruct{ > > int (*foo)(int); > > }; > > > > Translates to D as this: > > > > struct MyStruct{ > > i

Re: Callbacks and interfacing with C

2012-10-30 Thread Alex Rønne Petersen
On 30-10-2012 11:13, Nick Sabalausky wrote: Ok, a C function pointer like this: struct MyStruct{ int (*foo)(int); }; Translates to D as this: struct MyStruct{ int function(int) foo; } But what about calling conventions? There isn't any "int extern(C) func