Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 971053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:54:07+00:00 2026-05-16T02:54:07+00:00

What are the key factors on using different calling conventions? When does someone know

  • 0

What are the key factors on using different calling conventions? When does someone know to use specific calling conventions such as __cdecl or __stdcall or __fastcall in different occasions.

Examples would be really apprciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:54:07+00:00Added an answer on May 16, 2026 at 2:54 am

    Most of the time you don’t need to worry about it. Usually you’ll use __cdecl, but only because that’s the default in Visual C++. C++ member functions, however, use the __thiscall convention by default in Visual C++

    A (rather common) situation where you really have to worry about calling conventions is when you pass callbacks to API functions, like those in the Windows API:

    // CALLBACK is #define'd as __stdcall 
    LRESULT CALLBACK MyWndProc(HWND hwnd, UINT msg 
        WPARAM wParam, LPARAM lParam); 
    // ... 
    windowClass.lpfnWndProc = &MyWndProc; 
    ::RegisterClass(&windowClass);
    

    Here, we declare MyWndProc() as having the __stdcall convention (CALLBACK is #define‘d as __stdcall). This is needed because the operating system expects that lpfnWndProc points to a WNDPROC, which uses the CALLBACK convention.

    Just about every Windows API function that accepts a callback requires the callback functions to use the __stdcall convention, and since __cdecl is usually the default, you must make this explicit (you would use CALLBACK for window procedures).

    This is extremely important because stack corruption can occur if the operating system attempts to call a non-__stdcall function. Unfortunately enough people get this wrong that Windows will actually check for calling convention mismatch specifically for window procedures.

    While __stdcall is required for callback functions passed to WinAPI functions, functions that accept a variable number of arguments must use the __cdecl calling convention, because only the caller will know how to properly pop the variable number of arguments off the stack. Since __cdecl is usually the default, you don’t need to explicitly specify __cdecl for functions that accept a variable number of arguments.

    I personally haven’t found a use for __fastcall, although I’m sure someone has.

    __clrcall is relevant only if you’re interacting with managed code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Request[key] vs Request.Params[key] vs Request.QueryString[key] Which method do you seasoned programmers use? and why?
table : id (integer primary key) data (blob) I use mysql and sqlalchemy. To
I'm using this class as my key to Hashmap with overriden hasCode() and equals()
When using KeyFactory kg = KeyFactory.getInstance(ALGORITHM) what are the different algorithms that could be
My DNN module encrypts some data using my public key and presents it to
I am using FactoryGirl and Rspec for testing. The model sets a foreign key
I have the following code $.post( /factory/set,{ key : value }, function(response) { });
Each key in dictionary has list of MANY integers. I need to iterate through
My key tools are Photoshop, Illustrator and Expression Blend. As much as I love
The key event is not listened by my Flex app. Since it is really

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.