calling convention stdcalll and cdecl call

This is a discussion on calling convention stdcalll and cdecl call within the Windows Programming forums, part of the Platform Specific Boards category; Hello everyone, Both stdcall and cdecl calling convention could support variable input parameters? Is that correct? (I think stdcall is ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    calling convention stdcalll and cdecl call

    Hello everyone,


    Both stdcall and cdecl calling convention could support variable input parameters? Is that correct?

    (I think stdcall is using RET N and cdecl is using ESP - N, so both are capable to handle variable number of input parameter, like printf?)

    BTW: I have this question because I have something in mind that only one of them supports variable number of parameters, but after reading assembly language code, I think both of them are able to support this feature?


    thanks in advance,
    George

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    No, stdcall can not support variable parameters, since the called function cleans up the stack. To do that, you need to know how much is passed on the stack when building the function, which, as you can probably figure out, printf() doesn't know when you compile printf(). You need to use cdecl for this purpose, so that the stack cleanup is done in the calling code.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21