-
Types...
I'm trying to make my own short version of the windows header stuff I use, like this for an MessageBox app:
Code:
#ifdef strict
struct handtp { int unused; };
typedef struct handtp* hand;
#else
#define hand void*
#endif
#define wusr __declspec(dllimport)
#define wapi __stdcall
#define pch const char *
#define uint unsigned int
wusr int wapi MessageBoxA (hand, pch, pch, uint);
int __stdcall WinMain (hand hInstance, hand hPrev, pch cmdline, uint showhow)
{
uint unsg = 0;
hand hnul = 0;
pch myadr;
char mystr[] = "mycapt";
myadr = &mystr[0];
MessageBoxA(hnul, myadr, myadr, unsg);
return 0;
}
Why does it not work? I'm getting an unresolved external for the MessageBoxA.
-
If you're not linking the required libs at build time then you need to get a pointer to the dll function at runtime. For that, you need LoadLibrary (to load the dll into your exe address space - don't forget to FreeLibrary when done) and GetProcAddress to return a pointer to the function you need; forward declaration is not enough, you should typedef a MessageBoxA function pointer.
There's an example of runtime dynamic linking here.
-
The right lib User32.lib is attached, the problem was my wusr definition didn't include extern "c". Now it works. However, there are debug symbols for my app but not for the DLLs. Where do debug symbols come from?