On Sat, Jul 20, 2013 at 08:31:56PM +0200, Freddie Chopin wrote: > > And the only differences are: > - WINAPI > - single parameter. > > WINAPI causes name-mangling - the linker checks for "libusb_error_name", > but the real name of this function for windows is "_libusb_error_name@4" > - all because of WINAPI and a single 4-byte parameter. The function > prototype here is crucial, because WINAPI calls are NOT normal function > calls and the configure test checks for a plain "normal" function.
Yes. The underlying reason is that C functions by default allow varying numbers of arguments and generate code that knows how many were actually passed (by using in the calling code ADD SP,n to remove them) but almost all WINAPI do not do that because the called function removes them. The mangling helps to prevent accidental linking of one kind with the other which would just blow up at runtime. (WINAPI is the equivalent of what Intel's PL/M-86 compiler did, aka Pascal calling convention. Microsoft once upon a time used Pascal or perhaps PL/M as their systems language. IAC, this called-func-removes-args way is efficient with the snag of not coping so well as C does with varying numbers of args.) I'm not sure the best way to fix the code - sorry - but I think it needs doing at the C (not linker) level. John ------------------------------------------------------------------------------ See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds. Start your free trial of AppDynamics Pro today! http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk _______________________________________________ OpenOCD-devel mailing list OpenOCD-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openocd-devel