Extern, how to import a function and rename it ?

BlitzMax Forums/BlitzMax Programming/Extern, how to import a function and rename it ?

Extern "win32"
 Function RegisterClassLALALALALALAL(lpWndClass:Byte Ptr) = "RegisterClassExA"
end extern


This works here - ie: no error.

However, actually calling RegisterClassLALALALALALAL results in:

F:/blitzmax/tmp/.bmx/untitled1.bmx.d.o(code+0x1e1): undefined reference to `RegisterClassExA'

Not the error above, so not sure what's happening there.

To fix the link error, you need to manually mung the symbol, ie:

'This works on my machine!
Extern "win32"
 Function RegisterClassLALALALALALAL(lpWndClass:Byte Ptr) = "_RegisterClassExA@4"
End Extern

RegisterClassLALALALALALAL Null 'just testin'


If you've got mingw installed (and mingw/bin in your path), you can use the 'nm' utility to look at symbols in an object or archive file, eg:

cd \blitzmax\lib
nm libuser32.a