From ea589120937fc65a5c28d8a0bf89409698dcbf25 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Fri, 15 Jul 2011 22:56:47 +0700 Subject: [PATCH] Hide every symbol except ZNCModInfo from modules. This means that now it's possible to have the same class names in different modules, which reduces chances of weird errors. Thanks to mclc for noticing this. --- Modules.h | 8 +++++++- configure.ac | 2 ++ modules/modperl/module.h | 6 ++++++ modules/modpython/module.h | 6 ++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Modules.h b/Modules.h index 5c019d9a..ac8709b1 100644 --- a/Modules.h +++ b/Modules.h @@ -53,9 +53,15 @@ template CGlobalModule* TModLoadGlobal(ModHandle p, return new M(p, sModName, sModPath); } +#if HAVE_VISIBILITY +# define MODULE_EXPORT __attribute__((__visibility__("default"))) +#else +# define MODULE_EXPORT +#endif + #define MODCOMMONDEFS(CLASS, DESCRIPTION, GLOBAL, LOADER) \ extern "C" { \ - bool ZNCModInfo(double dCoreVersion, CModInfo& Info); \ + MODULE_EXPORT bool ZNCModInfo(double dCoreVersion, CModInfo& Info); \ bool ZNCModInfo(double dCoreVersion, CModInfo& Info) { \ if (dCoreVersion != VERSION) \ return false; \ diff --git a/configure.ac b/configure.ac index a80e3f93..0c1150e3 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,7 @@ AC_PROG_GREP AC_PROG_SED AC_CANONICAL_HOST AC_SYS_LARGEFILE +gl_VISIBILITY appendLib () { if test "$LIBS" != ""; then @@ -268,6 +269,7 @@ AC_ARG_WITH( [module-data-prefix], [DATADIR="${datadir}/znc"] ) appendMod "$CXXFLAGS" +appendMod "$CFLAG_VISIBILITY" if test -z "$ISSUN" -a -z "$ISDARWIN" -a -z "$ISCYGWIN"; then # This is an unknown compiler flag on some OS diff --git a/modules/modperl/module.h b/modules/modperl/module.h index 3080bb5f..decebfe4 100644 --- a/modules/modperl/module.h +++ b/modules/modperl/module.h @@ -10,6 +10,9 @@ #include "Modules.h" +#if HAVE_VISIBILITY +#pragma GCC visibility push(default) +#endif class CPerlModule : public CModule { CString m_sPerlID; VWebSubPages* _GetSubPages(); @@ -171,3 +174,6 @@ inline double GetVersion() { inline CString GetVersionExtra() { return VERSION_EXTRA; } +#if HAVE_VISIBILITY +#pragma GCC visibility pop +#endif diff --git a/modules/modpython/module.h b/modules/modpython/module.h index 16ab606d..3e2fa50b 100644 --- a/modules/modpython/module.h +++ b/modules/modpython/module.h @@ -15,6 +15,9 @@ public: class CModPython; +#if HAVE_VISIBILITY +#pragma GCC visibility push(default) +#endif class CPyModule : public CModule { PyObject* m_pyObj; CModPython* m_pModPython; @@ -224,3 +227,6 @@ public: } }; +#if HAVE_VISIBILITY +#pragma GCC visibility pop +#endif