I'm attempting to use an existing .dll file from within my C code. My coworker who created this .dll has a simple example written in C++ that uses this file, which example code I'm able to use with no problems.
However, I'm now attempting to "translate" his C++ code for use in my own C code, and so far have been getting long lists of compiler errors (understandably) because I'm attempting to use his C++ syntax within my C file. After searching online & on this forum, I haven't yet encountered the information I need, in order to convert his C++ code into a C syntax that will compile.
This is his example code:
Code:int a = 5, b = 2; typedef int (*sumPointer)(int a, int b); // Shorthand to make other lines shorter HINSTANCE dll; // Pointer to the .dll sumPointer sum; // Pointer to "sum" function within the .dll dll = LoadLibrary("RC.dll"); sum = (sumPointer)GetProcAddress(dll, "sum"); sum(a,b);
Once I can get this simple example working within my C code, I'll be able to apply this same principle to the real .dll & function calls that I need to use. (I'm aware that the comment indicators above need to be changed to C format, for starters.)
I appreciate any suggestions you have that will allow me to properly implement the above code in C. Thanks!