Forum > FPC development

MS C++ ThisCall


Hi folks,
this question was asked sometime ago in this forum: supports FPC the "thiscall" calling convention. And the answer is: no.
And normaly nobody needs this, BUT: the ASIO interface from Steinberg uses no calling convention keyword, so therefore the standard calling convention will be used in C++, and this is "thiscall".
A workaround with a C++ DLL with stdcall incapsulating the thiscall will be possible, but not beautiful  :P

So I tried to work out a solution. What I've solved already:
1) Lazarus knows the keyword "thiscall" and highlights, etc.
2) FPC can compile thiscall... but not correct at the moment

Since "thiscall" is just for the i386 on windows, I've only make changes on the i386 compiler.
I've added a tcpuparamanager procedure create_msvcthiscall_paraloc_info for the calling convention "thiscall".
Since parameter passing is the sames as stdcall, I used this as a base.
for thiscall, in ECX the "this" pointer must be loaded. So here I need to add an Register (ECX) to the parameters.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---if (side=callerside) then        begin            paraloc:=hp.paraloc[side].add_location;            paraloc^.size:=OS_ADDR;                            paraloc^.def:=methodpointertype;                            paraloc^.loc:=LOC_REGISTER;                            paraloc^.register:=newreg(R_INTREGISTER,parasupregs[parareg],cgsize2subreg(R_INTREGISTER,paracgsize));                            inc(parareg);        end;
The compiler crashes now, with  Fatal: Internal error 200501162 on Pushdata in line 145 of i386/cgcpu.pas.
Seems it tries to push the LOC_REGSITER parameter location on the stack, :o

So some help would be wonderful  :)

Well, google for the AsioVST package that TobyBear and me and later TobyBear and Christian wrote about - more than - 20 years ago.... The ASIO part is largely mine, the VST part largely by Frederic VanMol. Will have a look, but it should be easy to find. If you can't, I probably still have it somewhere.
Note that Christian was not very generous is giving credits. That's why I quit the scene. He presented my code as if it was written by him.... Bad idea.... Then again he was very young at the time.

Note I left out one person involved that made even static linking possible, but I forgot his name.
Will quote him when I find the code. Anyway: it has been done and in a proper way.

Thanks Thaddy,

I found the OpenASIO.dll hint in your source. Thx. This will help for my work with ASIO.

Edit: the OpenASIO.dll do not work. It's crashing all the time.
I now wrote my own (working) warpper-DLL, to refresh my C++ knowledge  %)
The OpenASIO DLL seems old. The thiscall was introduced in VS2005. And Im testing with ASIO4All which is uptodate.
Maybw before 2005 their is another calling convention used ascdefaulr in c++?

But the issue with the compiler remains  ;)


[0] Message Index

Go to full version