Basic extern function


Recommended Posts


I start to learn using extern in DF. I'm pretty much following the manual but still receiving error (the c file is not compiled). Please give me some hint to complete.  

I created a simple c file that will return x+y as show below and saved as C:\add.c

#include <stdio.h>

int calculation(int x, int y);

int main ()
    int total;
    total = calculation(100, 800);

int calculation(int x, int y)
    return (x + y);


I created an extern function in DF : extern("C:\add.c", "long calculation(long, long)", "add2nums", "stdcall")

and then call this function:

global add2

add2 = add2nums(20, 80)


Link to comment
Share on other sites

extern() can only load compiled DLL's.  DAQFactory isn't a C compiler, so can't read and execute plain old C code.  You have to use a compiler, and even Microsoft has a free one, to convert your C / C++ or other language code into a DLL.  It has to be a proper DLL too, with non-decorated function names.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.