c++ - 这个额外的关键字在这个 C++ 类声明中意味着什么?

标签 c++

我正在查看一些声明如下类的 C++ 代码:

class LIBSBML_EXTERN LayoutModelPlugin : public SBasePlugin

LIBSBML_EXTERN 关键字有什么用?

最佳答案

这是一个宏。我不确定您正在使用什么库,但可能是具有您可以在此处看到的定义的宏:https://github.com/copasi/copasi-dependencies/blob/master/src/libSBML/src/sbml/common/extern.h

#if ( ! defined LIBSBML_STATIC )
/**
 * The following ifdef block is the standard way of creating macros which
 * make exporting from a DLL simpler. All files within this DLL are
 * compiled with the LIBSBML_EXPORTS symbol defined on the command line.
 * This symbol should not be defined on any project that uses this
 * DLL. This way any other project whose source files include this file see
 * LIBSBML_EXTERN functions as being imported from a DLL, wheras this DLL
 * sees symbols defined with this macro as being exported.
 *
 * (From Andrew Finney's sbwdefs.h, with "SBW" replaced by "LIBSBML" :)
 */
#if defined(LIBSBML_EXPORTS)
#  define LIBSBML_EXTERN __declspec(dllexport)
#else
#  define LIBSBML_EXTERN __declspec(dllimport)
#endif

#else
#  define LIBSBML_EXTERN
#endif  /* LIBSBML_STATIC */

如果需要,它用于将类定义与 DLL 连接。

关于c++ - 这个额外的关键字在这个 C++ 类声明中意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60084878/

相关文章:

c++ - 我们可以有像 map<string,pair<string,list>> 这样的数据结构吗?

c++ - 字符串连接查询c++

c++ - 为什么没有 set_union 等使用容器类型而不是迭代器的便利函数?

c++ - 在磁盘上写入时,我应该使用尽可能小的类型吗?

C++内存泄漏与否

c++ - spirit boost : parameter type when using semantic actions and phoenix

c++ - 使用 C++ 原子库,我应该使用什么内存顺序进行加载,然后进行比较交换?

c++ - 使用 GDB 进入模板类

c++ - 在 C++ 中显式静态初始化为零

c++ - 使用 Visual Studio 构建 GMP 库?