diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-08-29 12:09:31 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-09-18 00:59:08 +0200 |
commit | 4bc048be257a08bf7878456cddba2f8db412cf39 (patch) | |
tree | 038dd27430168d1844ba4551cd967362294f1e94 | |
parent | 60f4fc8b706db9cbeacd5dc4886a7aa347daafc0 (diff) |
Let qVersion() be extern "C" if this is not a namespace build
This allows one to even dlopen() QtCore and call qVersion, to figure
out which version it is. A bit crazy, but someone might want to do it.
Change-Id: I932460515d07bed3f0e41c8ab2b46fc268ca73ff
Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
-rw-r--r-- | src/corelib/global/qglobal.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index ac67d33986..66b5049769 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -333,6 +333,19 @@ typedef double qreal; do { extern int QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); \ QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); } while (0) +/* + * If we're compiling C++ code: + * - and this is a non-namespace build, declare qVersion as extern "C" + * - and this is a namespace build, declare it as a regular function + * (we're already inside QT_BEGIN_NAMESPACE / QT_END_NAMESPACE) + * If we're compiling C code, simply declare the function. If Qt was compiled + * in a namespace, qVersion isn't callable anyway. + */ +#if !defined(QT_NAMESPACE) && defined(__cplusplus) && !defined(Q_QDOC) +extern "C" +#endif +Q_CORE_EXPORT const char *qVersion() Q_DECL_NOTHROW; + #if defined(__cplusplus) #ifndef Q_CONSTRUCTOR_FUNCTION @@ -558,7 +571,6 @@ Q_NORETURN Q_CORE_EXPORT void qTerminate() Q_DECL_NOTHROW; # endif #endif -Q_CORE_EXPORT const char *qVersion() Q_DECL_NOTHROW; Q_CORE_EXPORT bool qSharedBuild() Q_DECL_NOTHROW; #ifndef Q_OUTOFLINE_TEMPLATE |