makepanda: Update checkPandaVersion.h

This makes it possible to include it multiple times in a single
translation unit, and/or multiple times in a single dynamic
library (and without excess code bloat, too).
This commit is contained in:
Sam Edwards 2018-05-24 14:57:09 -06:00
parent 339e1ce4d8
commit 35ab16d38f

View File

@ -2606,18 +2606,21 @@ PANDAVERSION_H_RUNTIME="""
CHECKPANDAVERSION_CXX=""" CHECKPANDAVERSION_CXX="""
# include "dtoolbase.h" # include "dtoolbase.h"
EXPCL_DTOOL_DTOOLUTIL int panda_version_$VERSION1_$VERSION2 = 0; EXPCL_DTOOL_DTOOLBASE int panda_version_$VERSION1_$VERSION2 = 0;
""" """
CHECKPANDAVERSION_H=""" CHECKPANDAVERSION_H="""
# ifndef CHECKPANDAVERSION_H
# define CHECKPANDAVERSION_H
# include "dtoolbase.h" # include "dtoolbase.h"
extern EXPCL_DTOOL_DTOOLUTIL int panda_version_$VERSION1_$VERSION2; extern EXPCL_DTOOL_DTOOLBASE int panda_version_$VERSION1_$VERSION2;
# ifndef WIN32 // Hack to forcibly depend on the check
/* For Windows, exporting the symbol from the DLL is sufficient; the template<typename T>
DLL will not load unless all expected public symbols are defined. class CheckPandaVersion {
Other systems may not mind if the symbol is absent unless we public:
explictly write code that references it. */ int check() { return panda_version_$VERSION1_$VERSION2; }
static int check_panda_version = panda_version_$VERSION1_$VERSION2; };
template class CheckPandaVersion<void>;
# endif # endif
""" """