Call C function - Access violation

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


On 03.01.2016 14:01, TheDGuy wrote:
> Okay, i think this C code should work (checked with cpp.sh):
>
> #import <stdio.h>
> char* write(char* text){
>      return text;
> }
> int main(void){
>      return 0;
> }

Uh, no. 1) In C it's include, not import. 2) Now you have two main 
functions, that can't work.

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?


More information about the Digitalmars-d-learn mailing list