Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>"bradtgmurray" is right, but for Visual C++ compilers, you need to explicitly export your function anyway. But using a .DEF file as proposed by "Serge - appTranslator" is the wrong way to do it.</p> <h2>What is the universal way to export symbols on Visual C++ ?</h2> <p>Using the declspec(dllexport/dllimport) instruction, which works for both C and C++ code, decorated or not (whereas, the .DEF is limited to C unless you want to decorate your code by hand).</p> <p>So, the right way to export undecorated functions in Visual C++ is combining the export "C" idiom, as answered by "bradtgmurray", and the dllimport/dllexport keyword.</p> <h2>An example ?</h2> <p>As an example, I created on Visual C++ an empty DLL project, and wrote two functions, one dubbed CPP because it was decorated, and the other C because it wasn't. The code is:</p> <pre><code>// Exported header #ifdef MY_DLL_EXPORTS #define MY_DLL_API __declspec(dllexport) #else #define MY_DLL_API __declspec(dllimport) #endif // Decorated function export : ?myCppFunction@@YAHF@Z MY_DLL_API int myCppFunction(short v) ; // Undecorated function export : myCFunction extern "C" { MY_DLL_API int myCFunction(short v) ; } ; </code></pre> <p>I guess you already know, but for completeness' sake, the MY_DLL_API macro is to be defined in the DLL makefile (i.e. the VCPROJ), but not by DLL users.</p> <p>The C++ code is easy to write, but for completeness' sake, I'll write it below:</p> <pre><code>// Decorated function code MY_DLL_API int myCppFunction(short v) { return 42 * v ; } extern "C" { // Undecorated function code MY_DLL_API int myCFunction(short v) { return 42 * v ; } } ; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload