Call C function - Access violation

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jan 3 05:17:29 PST 2016


On 03.01.2016 14:12, anonymous wrote:
> You shouldn't get a segfault, though. You should get some compile/link
> error. Are you compiling the right files? Can the segfault be from
> something other than your program?

Oh, I see what's probably happening:

You compile the D program, but you don't compile and/or don't link the C 
object file. It segfaults then when trying to call the C function.

You need to compile the C file and pass it to dmd or the linker. For 
example:

gcc -c -otest.c.o test.c
dmd test.d test.c.o
./test


More information about the Digitalmars-d-learn mailing list