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 接口。
推荐阅读
- python - 使用 matplotlib 子图绘制散点图
- angular - Angular 应用程序和另一个 Java/Servlet/JSP 应用程序之间基于 SAML 的 SSO
- c++ - 如何将 lambda/std::function/Functor 传递给可变参数函数
- node.js - 访问使用 node.js 和 express.js 构建的 aws beanstalk 域时出现 CONNECTION_REFFUSED 错误
- jquery - jquery:从子元素中选择最近的前一个元素
- flutter - 错误:名称“用户”在库“package:firebase_auth/firebase_auth.dart”和“package:quizmaker/models/user.dart”中定义
- swiftui - SwiftUI:自定义视图修饰符不符合 ViewModifier?
- sql - 与附加字段的一对多关系
- javascript - 我是编码新手,我正在尝试使用多个 || (或)在 javascript 中的 if 语句条件中
- c# - 如何为 TextureRect 着色?