What is the use of keyword __cdel in function signature.

Discussion in 'C Programming' started by code break, Apr 6, 2006.

  1. code break

    code break Guest

    Hi all,

    I came across some unexpected funtion definition as follows

    int __cdel function_name(int arg1,int arg2)
    {
    statements ;
    .
    .
    }

    can any one tell me about the use of keyword __cdel in above function
    defintion..

    it help lot for me .
     
    code break, Apr 6, 2006
    #1
    1. Advertisements

  2. There is no __cdecl keyword in standard C. It's an extension
    implemented by your compiler. (It probably specifies something about
    the calling convention, something that the compiler should normally be
    able to decide for itself.)

    For more information, consult the documentation for your compiler.
    Failing that, a Google search for "__cdecl" gets 157,000 hits.
    Failing that, try a newsgroup appropriate to your compiler and/or
    operating system.
     
    Keith Thompson, Apr 6, 2006
    #2
    1. Advertisements

  3. code break

    Jaspreet Guest

    __cdecl is a C/C++ function / method calling convention. It is also a
    default calling behavior for C functions. It allows for variable
    arguments unlike __stdcall calling convention. The arguments are passed
    right to left. It is the responsiblity of calling function to do stack
    cleanup.

    You would probably not need to use __cdecl since its the default unless
    you have specified __stdcall in compiler options.

    For a much better explanantion take help from google.
     
    Jaspreet, Apr 6, 2006
    #3
  4. code break

    Jaspreet Guest

    Forgot to add that the above explanation is from Microsoft VC++ point
    of view.
     
    Jaspreet, Apr 6, 2006
    #4
  5. code break

    Bas Wassink Guest

    Nobody seems to notice that the OP is asking about '__cdel', not '__cdecl'.

    Bas
     
    Bas Wassink, Apr 6, 2006
    #5
  6. code break

    Jaspreet Guest

    Silly me. Thanks for pointing that out. Not only me even Keith also got
    it wrong. After all to err is to human. :)
     
    Jaspreet, Apr 7, 2006
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.