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

  • Home
  • SEARCH
  • 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 6231771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:59:34+00:00 2026-05-24T09:59:34+00:00

I am writing a DLL for a third party application. The main software engineer

  • 0

I am writing a DLL for a third party application. The main software engineer mentions that the application uses the __cdecl (/Gd) calling convention. That I need to make sure that I use that.

Additionally, the third party has provided to me a C++ DLL skeleton which exports the functions as follows:

#ifdef _EXPORTING
  #define DECLSPEC    __declspec(dllexport)
#else
   #define DECLSPEC    __declspec(dllimport)
#endif

#ifdef __cplusplus
   extern "C" {  
#endif

DECLSPEC int ICD_Create(char* id);
....
....

I am kind of confused. Why the functions are being exported using __declspec convention instead of __cdedl?? does __declspec support _cdecl?

Thanks.

  • 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-24T09:59:35+00:00Added an answer on May 24, 2026 at 9:59 am

    __declspec() and __cdecl are addressing two different aspects of calling the function, and you can (and in this case by the sounds of it you should) use both.

    __cdecl specifies the calling convention, which specifies how parameters are passed to the function via the stack, and, very importantly, who cleans up the stack afterwards (in the case of __cdecl it is the caller who tidies up).

    __declspec(dllimport/dllexport) is used to simplify exporting function definitions from a DLL: you don’t need to use them, but the other ways of exporting functions are quite klunky.

    It is probably a good idea to explicitly use __cdecl rather than doing what the code snippet you have has done, which is rely on the compiler to choose the calling convention. You can override this with command-line switches I think, and I believe the default is different depending on whether you are compiling C or C++ code, so more explicit is (as usual) better.

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

Sidebar

Related Questions

I am writing a module for a third party application; the application uses __cdecl
I'm writing a small DLL component that needs to access two third party components
I am writing a DLL which is loaded by a third party application (The
I'm writing applications that interoperate with a third-party application. This application exposes an API
I am writing a python extension module that needs to link with a third-party
I'm writing a DLL add-on for an application that internally has large parts written
I am writing a .Net COM DLL that runs inside a native Windows application.
We're writing a JNI DLL to wrap a third-party DLL. In our DLL, we're
I have a third-party product, a terminal emulator, which provides a DLL that can
There is a bug in a third party .DLL file that we're using and

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.