From f9717e35cab505cfca95e708b53336bd7bf78f56 Mon Sep 17 00:00:00 2001 From: danieldg Date: Tue, 6 Oct 2009 16:50:48 +0000 Subject: Take advantage of link errors to check API_VERSION at module load time git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11805 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/modules.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/modules.h b/include/modules.h index ca345dbc1..d59bdf05b 100644 --- a/include/modules.h +++ b/include/modules.h @@ -104,8 +104,8 @@ struct ModResult { } }; -/** If you change the module API, change this value. */ -#define API_VERSION 13000 +/** If you change the module API in any way, increment this value. */ +#define API_VERSION 131 class ServerConfig; @@ -226,13 +226,14 @@ do { \ #define IS_AWAY(x) (!x->awaymsg.empty()) /** Holds a module's Version information. - * The four members (set by the constructor only) indicate details as to the version number - * of a module. A class of type Version is returned by the GetVersion method of the Module class. - * The flags and API values represent the module flags and API version of the module. - * The API version of a module must match the API version of the core exactly for the module to - * load successfully. + * The members (set by the constructor only) indicate details as to the version number + * of a module. A class of type Version is returned by the GetVersion method of the Module class. + * + * The core provides only one implementation of the template, causing a run-time linking + * error when attempting to load a module compiled against a different API_VERSION. */ -class CoreExport Version : public classbase +template +class CoreExport VersionBase : public classbase { public: /** Module description @@ -242,16 +243,17 @@ class CoreExport Version : public classbase */ const std::string version; - /** Flags and API version + /** Flags */ - const int Flags, API; + const int Flags; /** Initialize version class */ - Version(const std::string &desc, int flags, - int api_ver = API_VERSION, const std::string& src_rev = VERSION " r" REVISION); + VersionBase(const std::string &desc, int flags = VF_NONE, int dummy = 0, const std::string& src_rev = VERSION " r" REVISION); }; +typedef VersionBase Version; + /** The ModuleMessage class is the base class of Request and Event * This class is used to represent a basic data structure which is passed * between modules for safe inter-module communications. -- cgit v1.2.3