D
D
Denis Savitsky2012-01-28 09:43:53
C++ / C#
Denis Savitsky, 2012-01-28 09:43:53

Kernel convention in C++ subroutines

What is the difference between the conventions of the C++ language and, for example, Pascal about working with the kernel in subroutines? This means that clearing the stack when exiting subroutines on assembler'e in C ++ is carried out automatically, but not in other languages.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rio, 2012-01-28
@qweewq

In C and C++, by default, the stack is cleared by the calling code after a call. This was done so that functions with a variable number of parameters would work (after all, only the calling code knows how many parameters it put on the stack). In Pascal, it is accepted that the called function itself cleans the stack.
Different operating systems may have different API calling conventions, Windows adopts the Pascal variant, so all Windows kernel functions are declared with the __stdcall modifier. Accordingly, the __cdecl modifier defines functions that use the sish parameter passing convention.

M
MikhailEdoshin, 2012-01-28
@MikhailEdoshin

Do you mean calling conventions , i.e. , stdcalletc. fastcall? Actually this is the difference, some clean, others do not. If you do not write your own libffi, then it remains only to monitor the correctness of the declarations.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question