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.
This commit is contained in:
Alexey Sokolov
2011-07-15 22:56:47 +07:00
parent efda366d44
commit ea58912093
4 changed files with 21 additions and 1 deletions

View File

@@ -53,9 +53,15 @@ template<class M> 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; \

View File

@@ -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

View File

@@ -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

View File

@@ -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