__stdcall calling conventions on global functions.

Started by
10 comments, last by Fruny 19 years, 10 months ago
daedalusd:

Yes and no. For the windows platform this is the only difference in the calling convention. It also changes the way the function name is scrambled for exportation, but AngelScript doesn't bother about that.

Perhaps I jumped the gun a bit when I said __stdcall and __thiscall are the same except for the object pointer. This is true for the MSVC compiler, but for g++ based compilers this is not true. I don't know how it is for other compilers. The various compilers are not in agreement on how to implement object method calls. And method pointers are even more complicated. But you can be pretty sure that __stdcall will work as you implemented it, as most compilers that work on the windows system can call Microsoft library functions. For other platforms like Linux I'm not sure that __stdcall even exists.

Please, do send me the code changes. It will be much faster for me to include it in the library that way (and I'll add your name to the contributions list :) You can send me the changed files, and I'll use WinMerge to find the differences.

Magmai Kai Holmlor:

Actually, the bstr type we are talking about is not the COM bstr, it is a simple byte string that I designed for AngelScript. Though it takes heavy influence from the COM bstr in that it stores the length just before the actual data, and also guarantees a null termination after the string data. (perhaps it was an unfortunate choice of name)

The correct choice in this case would be MessageBoxA().

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
MSDN says:
Quote:
Keyword       Stack      Parameter passing              cleanup__cdecl       Caller     Pushes parameters on the stack,                          in reverse order (right to left) __stdcall     Callee     Pushes parameters on the stack,                          in reverse order (right to left) __fastcall    Callee     Stored in registers, then pushed on stack thiscall      Callee     Pushed on stack; this pointer stored in ECX(not a keyword)
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement