Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is that your header file meant for compilation into a DLL contains code! So "main.exe" exectutes a local copy of the inline functions (such as Base::sys), but the actual implementation of "Base::setSystem" is compiled into the DLL. So when main invokes the "setSystem" call, it calls the Base::setSystem linked into the DLL. But when it compiles Base::sys, it sees that an inline implementation exists and uses that.</p> <p>In other words, you have two copies of "Base" floating around. One that lives in the EXE and another that lives in the DLL. And the inline functions confuse the compiler and linker as to which version to invoke.</p> <p>Don't put inline functions (or code for that matter) in a header file where the implementation is meant to live in a DLL.</p> <p>Easy fix:</p> <pre><code>// base.h (gets included by main) class Base { private: static Filesystem * filesystem; static Logger * logger; static System * system; public: static void setFilesystem(Filesystem * filesystem_); static void setApplication(Application * application_); static void setLogger(Logger * logger_); static void setSystem(System * system_); static Filesystem * fs(); static Logger * log(); static System * sys(); }; // base.cpp (gets compiled only within the DLL System* Base::sys() { return system; } // repeat "get" function for "log" and "fs" as well </code></pre> <p>Right fix:</p> <p>You really, really, really should not be attempting to export C++ classes from DLLs. It's allowed, but gets complicated really quick when you start inlining code in header files and changing interfaces in different versions of the DLL.</p> <p>A better approach is to export a pure "C" library from a DLL. And don't expose the internals in header files. OR, if you do want to export C++ classes, do it with COM interfaces. Then all you are doing is putting an interface declaration into your header file.</p>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    1. 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