diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-06 16:50:48 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-06 16:50:48 +0000 |
commit | f9717e35cab505cfca95e708b53336bd7bf78f56 (patch) | |
tree | 04c1fd9c4d34b224f9816fd501b18809cc01152e /include | |
parent | 2fabf1ccd1897c55b58757d8ed722a025f93554f (diff) |
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
Diffstat (limited to 'include')
-rw-r--r-- | include/modules.h | 26 |
1 files changed, 14 insertions, 12 deletions
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<int api> +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<API_VERSION> 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. |