Extern "C" int __declspec(dllexport)

In this article, You will learn about extern "C" int __declspec(dllexport). with help of this article , I want to explain deeply about extern "C" directive and the __stdcall keyword

Find the detail about extern "C" int __declspec(dllexport)

When providing an interface between modules that are built using two different vendor's compilers, it is important to ensure that the modules use common calling- and naming- conventions. This document discusses interface techniques for mixing modules created with Microsoft Visual C++ and modules created with Power++ or Watcom C/C++.

To provide an interface between Visual C++ and Power++ or Watcom C/C++, you will need to export and import functions and/or variables. Function definitions and prototypes should include the extern "C" directive and the __stdcall keyword. The former forces C linkage (i.e., turns off C++ name mangling); the latter ensures the standard Win32 calling convention is used. Variable definitions and declarations should also include the extern "C" directive.

If you want to write an Power++ or Watcom C/C++ EXE that calls functions or accesses variables exported from a Visual C++ DLL, then you must use the Visual C++ lib command to create an import library for the DLL. This import library can then be added to your Power++ or Watcom IDE project. The import library can also be used with the Watcom C/C++ wlink command if you are using command-line tools.

Calling Exported FunctionsFor each exported function in the DLL that is to be called from the EXE, do the following:In the DLL source, define the function as: