2

I'm looking at some C++ code which declares a class like this:

class LIBSBML_EXTERN LayoutModelPlugin : public SBasePlugin

What is the LIBSBML_EXTERN keyword for?

CiaranWelsh
  • 7,014
  • 10
  • 53
  • 106
  • 2
    It's a macro. You'll need to search your code base for its definition. – NathanOliver Feb 05 '20 at 22:15
  • It's not a keyword; keywords are defined by the language specification. It's probably a macro that's defined by some library that this code is using. – Pete Becker Feb 05 '20 at 22:15
  • 1
    Does this answer your question? [C++ method declaration including a macro](https://stackoverflow.com/questions/10210449/c-method-declaration-including-a-macro) – Enlico Feb 05 '20 at 22:18

2 Answers2

2

It's a macro. I'm not sure exactly what libraries you're using, but likely it's the macro with the definition you can see here: 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 */

It is used to interface the class definition with DLLs, if required.

N. Shead
  • 3,828
  • 1
  • 16
  • 22
  • Got it, this makes sense - thought there was another mistical part of C++ class declarations for a moment there. Thanks! – CiaranWelsh Feb 05 '20 at 22:29
0

It is a macro, something that you would define like this:

#define LIBSBML_EXTERN whatever

where whatever is what the compiler puts in place of LIBSBML_EXTERN before compiling.

Enlico
  • 23,259
  • 6
  • 48
  • 102