Frage

I have a simple question. What does "WINAPI" mean in following definition:

int WINAPI WinMain ();

I think, that the return type is int and the function name is WinMain, but I can't figure out, what "WINAPI" means in this case.

Thanks :)

War es hilfreich?

Lösung

It's a macro that is used to specify the calling convention of the function.

The Microsoft documentation defines it as:

#define WINAPI __stdcall

The meaning of __stdcall is documented here.

Andere Tipps

It is explained here:

http://msdn.microsoft.com/en-us/library/windows/desktop/ff381406(v=vs.85).aspx

WINAPI is the calling convention. A calling convention defines how a function receives parameters from the caller. For example, it defines the order that parameters appear on the stack.

It is also already answered here.

Typical c calls are compiled using what's known as cdecl. In cdecl the caller cleans up the arguments pushed on the stack.

WINAPI, also known as "standard call" means that the called function is responsible for cleaning up the stack of its arguments.

The MS compiler will prefix a cdecl call with a _, while a WINAPI gets a leading _ and gets an @{BYTES-NEEDED} prepended to the function name when it mangles the function names.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top