Search code examples
c++multithreadingwxwidgets

wxWidgets in c++ on windows


I was reading this particular code snippet:-

  class WXDLLIMPEXP_CORE wxCommandEvent : public wxEvent, public wxEventBasicPayloadMixin

this is defined in event.h header file , i didn't understand "WXDLLIMPEXP_CORE".

Thanks


Solution

  • If we have a look at where it is defined we see

    #ifdef WXMAKINGDLL_CORE
    #    define WXDLLIMPEXP_CORE WXEXPORT
    #    define WXDLLIMPEXP_DATA_CORE(type) WXEXPORT type
    #    if defined(HAVE_VISIBILITY)
    #        define WXDLLIMPEXP_INLINE_CORE WXEXPORT
    #    else
    #        define WXDLLIMPEXP_INLINE_CORE
    #    endif
    #elif defined(WXUSINGDLL)
    #    define WXDLLIMPEXP_CORE WXIMPORT
    #    define WXDLLIMPEXP_DATA_CORE(type) WXIMPORT type
    #    if defined(HAVE_VISIBILITY)
    #        define WXDLLIMPEXP_INLINE_CORE WXIMPORT
    #    else
    #        define WXDLLIMPEXP_INLINE_CORE
    #    endif
    #else /* not making nor using DLL */
    #    define WXDLLIMPEXP_CORE
    #    define WXDLLIMPEXP_DATA_CORE(type) type
    #    define WXDLLIMPEXP_INLINE_CORE
    #endif
    

    The comments elsewhere in the file are pretty explanatory as to what is happening, but a brief summary is that there are three cases, we are making a DLL, using a DLL or not using one at all. The last case is the simplest, if we are not using DLLs at all then they are defined away to nothing. If we are making a DLL then it marks the class as exported, and if we are using a DLL then it marks the class as imported.