diff options
author | Jędrzej Nowacki <jedrzej.nowacki@nokia.com> | 2011-11-28 15:40:35 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-01 14:35:42 +0100 |
commit | e650859dc9c26b3d411c534286f477d786723a74 (patch) | |
tree | d06bb9f7b6623b45834ab1abb7281f84bf7745a8 /src/corelib/global/qglobal.h | |
parent | 389538c2e76698944834526a2f36284cce109afe (diff) |
Improve Q_CONSTRUCTOR_FUNCTION and Q_DESTRUCTOR_FUNCTION macros.
By adding anonymous namespace and static linkage we are reducing
visibility of implementation of these macros.
This patch also fixes warning about a declared but unused variable which
was issued by gcc 4.6 for Q_CONSTRUCTOR_FUNCTION.
Change-Id: I2cb70ad4c93f6f77e5518420abcce6fd4cadccfa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Diffstat (limited to 'src/corelib/global/qglobal.h')
-rw-r--r-- | src/corelib/global/qglobal.h | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 20f3ca9351..aa6a1e853c 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -373,23 +373,6 @@ namespace QT_NAMESPACE {} Should be sorted most to least authoritative. */ -#if defined(__ghs) -# define Q_OUTOFLINE_TEMPLATE inline - -/* the following are necessary because the GHS C++ name mangling relies on __*/ -# define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \ - static const int AFUNC ## _init_variable_ = AFUNC(); -# define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC) -# define Q_DESTRUCTOR_FUNCTION0(AFUNC) \ - class AFUNC ## _dest_class_ { \ - public: \ - inline AFUNC ## _dest_class_() { } \ - inline ~ AFUNC ## _dest_class_() { AFUNC(); } \ - } AFUNC ## _dest_instance_; -# define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC) - -#endif - /* Symantec C++ is now Digital Mars */ #if defined(__DMC__) || defined(__SC__) # define Q_CC_SYM @@ -827,17 +810,23 @@ namespace QT_NAMESPACE {} #ifndef Q_CONSTRUCTOR_FUNCTION # define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \ - static const int AFUNC ## __init_variable__ = AFUNC(); + namespace { \ + static const struct AFUNC ## _ctor_class_ { \ + inline AFUNC ## _ctor_class_() { AFUNC(); } \ + } AFUNC ## _ctor_instance_; \ + } + # define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC) #endif #ifndef Q_DESTRUCTOR_FUNCTION # define Q_DESTRUCTOR_FUNCTION0(AFUNC) \ - class AFUNC ## __dest_class__ { \ - public: \ - inline AFUNC ## __dest_class__() { } \ - inline ~ AFUNC ## __dest_class__() { AFUNC(); } \ - } AFUNC ## __dest_instance__; + namespace { \ + static const struct AFUNC ## _dtor_class_ { \ + inline AFUNC ## _dtor_class_() { } \ + inline ~ AFUNC ## _dtor_class_() { AFUNC(); } \ + } AFUNC ## _dtor_instance_; \ + } # define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC) #endif |