_Cdecl和cdecl是什么意思。

解决方案 »

  1.   

    __cdeclMicrosoft Specific —>This is the default calling convention for C and C++ programs. Because the stack is cleaned up by the caller, it can do vararg functions. The __cdecl calling convention creates larger executables than __stdcall, because it requires each function call to include stack cleanup code. The following list shows the implementation of this calling convention.Element Implementation 
    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 
    Note   For related information, see Decorated Names. Place the __cdecl modifier before a variable or a function name. Because the C naming and calling conventions are the default, the only time you need to use __cdecl is when you have specified the /Gz (stdcall) or /Gr (fastcall) compiler option. The /Gd compiler option forces the __cdecl calling convention.Example
    In the following example, the compiler is instructed to use C naming and calling conventions for the system function:// Example of the __cdecl keyword
    _CRTIMP int __cdecl system(const char *);//From MSDN
      

  2.   

    __cdecl c调用约定
    也就是函数的调用者将参数从右向左压堆栈后调用函数,函数完成后由调用者恢复堆栈,好处是可以声明参数不固定的函数