On 2011-03-18 19:54, Adrian Iliescu wrote:
Is there a way to call a C function without having to screw around with the
linker on the command line?  In C#, for example, this is all you have to do:

         [DllImport( @"..\Debug\CLibTest.dll" )]    //location
         internal static extern int MyTestResult(); //name of function

         void CSUsingCLib()
         {
             int result = MyTestResult(); //use it
         }

With pragma(lib, "lib"); you can link to a library: http://www.digitalmars.com/d/2.0/pragma.html

And then using extern(C) as usual to declare the function. You can also use "dlopen" and friends on Posix and whatever the equivalent is for Windows.

--
/Jacob Carlborg

Reply via email to