WinMain

Started by
5 comments, last by HyprLogik 23 years, 10 months ago
Hi. When creating a plain-vanilla window using: int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd ) { ... } what does the WINAPI part of the declaration mean? Is it a return type just like ''int''? Thanks. |-|A[k3R$Z R \/\/|-|AT |V|Ak3 t|-|3 \/\/0R|_D g0 R0|_||\|D!!
|-|A[k3R$Z R //|-|AT |V|Ak3 t|-|3 //0R|_D g0 R0|_|||D!!
Advertisement
WINAPI tells the compiler and linker that that function is loaded from a dll somewhere else.
WINAPI is just a type declaration. PASCAL i believe for Intel 80x86 processors. the use of WINAPI instead of PASCAL is simply for source code portability issues.


typedef PASCAL WINAPI;
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
WINAPI is the calling convention which is the same as PASCAL.
It states the method in asm that should be created by the compiler for this function to return data. Usually WINAPI will used with .dll''s and Windows Shell.

typedef WINAPI FAR PASCAL.. ?? i think

typedef FAR PASCAL WINAPI .. ?? sorry about the mistake.

Actually, just take a look at windef.h for your answers.

Depdning on the platform WINAPI is defined as various things. When _MAC is defined WINAPI is defined as CDECL which is defined as __cdecl. Otherwise it is defined as __stdcall. __stdcall has the following charateristics:

Argument-passing order: Right to left.

Argument-passing convention: By value, unless a pointer or reference type is passed.

Stack-maintenance responsibility: Called function pops its own arguments from the stack.

Name-decoration convention: An underscore (_) is prefixed to the name. The name is followed by the at sign (@) followed by the number of bytes (in decimal) in the argument list. Therefore, the function declared as int func( int a, double b ) is decorated as follows: _func@12

Case-translation convention: None
[end]

I'm pretty sure unless noted otherwise functions by default use the __cdecl calling convention which has the following characteristics:

Argument-passing order: Right to left

Stack-maintenance responsibility: Calling function pops the arguments from the stack

Name-decoration convention: Underscore character (_) is prefixed to names

Case-translation convention: No case translation performed
[end]

When PASCAL is used it is defined as __stdcall anyway. __pascal calling convention is obsolete.

Edited by - Sheltem on June 21, 2000 1:17:41 AM
Thanks for the explanations. I''ll probably be posting plenty of questions in the near future ''cause I''m now just learning this stuff.

|-|A[k3R$Z R \/\/|-|AT |V|Ak3 t|-|3 \/\/0R|_D g0 R0|_||\|D!!
|-|A[k3R$Z R //|-|AT |V|Ak3 t|-|3 //0R|_D g0 R0|_|||D!!

This topic is closed to new replies.

Advertisement