NO

Author Topic: PASCAL  (Read 4232 times)

czerny

  • Guest
PASCAL
« on: September 28, 2014, 05:41:33 PM »
I always thought that PASCAL (like WINAPI and CALLBACK) is the same as __stdcall (see windefs.h).

But I found other definitions which said that the parameters are pushed left to right. So I want to clarify this:

See for example:

http://msdn.microsoft.com/de-de/library/system.runtime.interopservices.comtypes.callconv(v=vs.110).aspx
http://de.wikipedia.org/wiki/Aufrufkonvention#Pascal
http://www.lowlevel.eu/wiki/Aufrufkonventionen#Pascal

I am engaged in the 'COM in plain C' Artikels from Jeff Glatt in the moment. He uses PASCAL too for the DLL interface of his
COM-objects. I suppose there is a reason!

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: PASCAL
« Reply #1 on: September 28, 2014, 10:25:17 PM »
'PASCAL' is not a C keyword, but a #def.
You'll find it in 'windef.h' line 93 as:
Code: [Select]
#define PASCAL  __stdcall

When using COM you should check in the  METHODDATA structure what calling method is used and act consistently on the INVOKE.
The COM used in Jeff Glastt articles generally don't use the INVOKE method of IUNKNOWN.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

czerny

  • Guest
Re: PASCAL
« Reply #2 on: September 29, 2014, 10:05:39 PM »
... use the INVOKE method of IUNKNOWN.
Do you mean the INVOKE method of IDispatch?

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: PASCAL
« Reply #3 on: September 30, 2014, 07:24:21 AM »
That Invoke in IDispatch is for late binding and it is slower / more complicate way to call COM function.
Look here or here
« Last Edit: September 30, 2014, 07:29:48 AM by TimoVJL »
May the source be with you

czerny

  • Guest
Re: PASCAL
« Reply #4 on: September 30, 2014, 09:35:17 AM »
That Invoke in IDispatch is for late binding and it is slower / more complicate way to call COM function.
Look here or here
I know this. But I have never hered of an Invoke methode in IUnknown!

czerny

  • Guest
Re: PASCAL
« Reply #5 on: September 30, 2014, 09:46:38 AM »
Let's return to the original question!

Are there differnt meanings of calling convention PASCAL?

1. #define __stdcall PASCAL
2. __stdcall (right to left), pascal (left to right) (Wikipedia)

What is CC_PASCAL?

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: PASCAL
« Reply #6 on: September 30, 2014, 09:56:08 AM »
As frankie says, PASCAL is only defined to __stdcall in Win32, in Win64 it is __fastcall.
So calling convention depends are you using x86 or x64.
Look here
« Last Edit: September 30, 2014, 09:58:06 AM by TimoVJL »
May the source be with you

czerny

  • Guest
Re: PASCAL
« Reply #7 on: September 30, 2014, 10:13:26 AM »
This http://msdn.microsoft.com/en-us/library/windows/desktop/ms221058(v=vs.85).aspx describes CC_PASCAL as an calling convention in an automation (COM) environment. So here is my parallel to Jeff Glatts Artikel.

CC_PASCAL is a 'left to right' pushing call!

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: PASCAL
« Reply #8 on: September 30, 2014, 10:18:21 PM »
... use the INVOKE method of IUNKNOWN.
Do you mean the INVOKE method of IDispatch?
Yes, INVOKE method of IDispatch.
I am very sorry for the inconvenience.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide