wxWidgets in c++ on windows

wxWidgets in c++ on windows

本文关键字:windows on c++ in wxWidgets      更新时间:2023-10-16

>我正在阅读这个特定的代码片段:-

  class WXDLLIMPEXP_CORE wxCommandEvent : public wxEvent, public wxEventBasicPayloadMixin

这是在event.h头文件中定义的,我不明白"WXDLLIMPEXP_CORE"。

谢谢

如果我们看一下它的定义,我们会看到

#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

文件中其他地方的注释对正在发生的事情进行了很好的解释,但简要总结一下,有三种情况,我们正在制作 DLL,使用 DLL 或根本不使用。最后一种情况是最简单的,如果我们根本不使用 DLL,那么它们就会被定义为零。如果我们正在制作一个 DLL,那么它将类标记为导出,如果我们使用 DLL,那么它将类标记为已导入。