Warning: C4251
-
I started a new .dll with Qt Creator and there I have example.cpp and a example.h.
Additionally a file named example_global.h has been automatically generated, where following is defined:
@
#if defined(DDDG_LIBRARY)define DDDGSHARED_EXPORT Q_DECL_EXPORT
#else
define DDDGSHARED_EXPORT Q_DECL_IMPORT
#endif
@
and in the example.h there is:
@
#include "dddg_global.h"
class DDDGSHARED_EXPORT Dddg {
//...
@In my project I do not have such a global header file. I entered this export stuff
@
#if defined(DDDG_LIBRARY)define DDDGSHARED_EXPORT Q_DECL_EXPORT
#else
define DDDGSHARED_EXPORT Q_DECL_IMPORT
#endif
@in each header where I got those warnings (each with different nomenclature).
So I assume I misunderstood the export functionality. I need one global header with that Q_DECL_EXPORT stuff, an each other class-header needs a
@
#include "dddg_global.h"
class DDDGSHARED_EXPORT Dddg {
//...
@
? When I create such a global header manually, how do I configure the properties settings, that the compiler recognize this header as such a global header? Or is this automatically when I include that in each header?
Or this is regardless and both ways are possible?Cheers Huck
-
A header is a header is a header. There is nothing special about it apart from that it contains only the export/import macros.
As you say, just include it in each class and add DDDGSHARED_EXPORT before each class that you wish (or need) to export and all should be good.
I tend to name the macro something like DDDGSHARED_API so as not to fool myself into thinking that it always resolves to Q_DECL_EXPORT but that's just for the benefit of my poor little brain.
As a side note, to enable symbol visibility with gcc you need to add
@
CONFIG += hide_symbols
@to your .pro file. I'm not sure why this is not enabled by default for gcc nowadays.
-
Add CONFIG += hide_symbols to your .pro file?
Unfortunately, I do not use gcc. It is the VC++ Compiler version 9 I think.
-
I was just mentioning it in case you ever decide to use GCC.