What is PASCAL in C++?

Hi!

I'm currently working on a program that shall transmit data via TCP/IP. OK, I have my problems with that, but this is not the point of my question.

My application crashes when I close it, deep inside MFC, where a socket is been checked. The declaration of the crashing (ASSERT-ing) function contains the word "PASCAL".

What is the meaning of it?

Thanks!

Marc
[412 byte] By [Marc from D] at [2007-11-20 1:34:19]
# 1 Re: What is PASCAL in C++?
PASCAL is a #define for __stdcall.

#define PASCAL __stdcall

Any compiler that supports development of Win32-based applications must support this or an equivalent one. A function that is marked with __stdcall uses the standard calling convention so named because all Win32 API functions (except the few that take variable arguments) use it. Functions that follow the standard calling convention remove the parameters from the stack before they return to the caller. This is the standard convention for Pascal (hence this #define). But in C/C++, the calling convention is that the caller cleans up the stack instead of the called function. __cdecl is the keyword to be used for such functions. Variable argument functions use the C/C++ calling convention.

If you look in WinDefs.h you'll see all these #defines:

#elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
#define CALLBACK __stdcall
#define WINAPI __stdcall
#define WINAPIV __cdecl
#define APIENTRY WINAPI
#define APIPRIVATE __stdcall
#define PASCAL __stdcall
#else

You are probablt looking at a WinAPI function. Windows adopted the standard calling convention (Pascal convention) because it reduces the size of the code. This was very important in the early days of Windows, when it ran on systems with 640 KB RAM.

Hope this helps.
cilu at 2007-11-10 23:17:57 >