Library Suggestion

Jeremy Jeremy_member at pathlink.com
Mon Mar 27 09:09:30 PST 2006


OK, I have another idea for easier library integration. :)

You have this at the top of your code:

#pragma(lib,"whatever.lib")

instead of having to do an "extern(C) void whatever_func010(int, int)" for every
function, just grab this information from unresolved symbols. Like:

--------------------------
#pragma(lib,"whatever.lib");

int main() {
int a, b;
whatever_func010(a,b);
return 0;
}
--------------------------

When it compiles, the 'whatever_func010' will be unresolved -- but you have the
symbol name and argument types -- you could use this information to create the
same information as in the "extern" definition line. Then, you wouldn't need to
explicitly define each function name -- just referencing the function (with the
correct argument types) will tell the linker the symbol name/args etc.

If you need to know the type (e.g. "C" as in "extern(C)") you could add that to
the #pragma line:

#pragma(lib,"whatever.lib",C);

Jeremy



More information about the Digitalmars-d mailing list