Qbasicnews.com

Full Version: Getting constants from a C DLL?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
*Warning, possible dumb question*

Is it possible to get the constants from a DLL?

This is what I am trying to do....

The GSL dlls have several constants defined (Pi, Euler's, etc). I have the .h files so I could hard code them in FB, but I think it would be better to get them from the DLL that way if a new version comes out its just a matter of dropping the new dll in (or at least it should be).

I understand the Declare (sub|function) bit, is it possible to do this with constants?
If they're #define'd in the .h, you can't get them from the DLL. If they're actual const variables, as in 'const int pi = 3;', then you should be able to do:
Code:
extern import pi as integer
print "pi = "; pi
They are #defined <insert profanity here>

Oh well,

Thanks
You can use the Win32 API, I have used LoadLibrary or GetModuleHandle and then GetProcAddress to get variables from a DLL. I don't have an example in FreeBASIC though.
But if they're #define'd, they're not variables; therefore, you can't get their addresses.