Move functions from an anonymous namespace in a header
authorThiago Macieira <thiago.macieira@intel.com>
Sat, 29 Dec 2012 18:05:12 +0000 (10:05 -0800)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 8 Jan 2013 12:50:38 +0000 (13:50 +0100)
Clang doesn't like functions declared in an anonymous namespace in a
header and then later not used. It treats those are static functions,
and the -Wunused-functions warning is printed for them.

Instead, declare them inline in a regular namespace and use it.

qclucene_global_p.h:106:19: error: unused function 'QStringToTChar' [-Werror,-Wunused-function]
    inline TCHAR* QStringToTChar(const QString &str)
                  ^

Change-Id: I94696d40693558ef105281c8ec6e30159c47844d
Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
src/assistant/clucene/qclucene_global_p.h

index e84fa28..c16e74d 100644 (file)
@@ -102,8 +102,8 @@ QT_BEGIN_NAMESPACE
 #   define CL_NS2(sub,sub2)
 #endif
 
-namespace {
-    TCHAR* QStringToTChar(const QString &str)
+namespace QtCLuceneHelpers {
+    inline TCHAR* QStringToTChar(const QString &str)
     {
         TCHAR *string = new TCHAR[(str.length() +1) * sizeof(TCHAR)];
         memset(string, 0, (str.length() +1) * sizeof(TCHAR));
@@ -116,7 +116,7 @@ namespace {
         return string;
     }
 
-    QString TCharToQString(const TCHAR *string)
+    inline QString TCharToQString(const TCHAR *string)
     {
         #if defined(UNICODE) || defined(_CL_HAVE_WCHAR_H) && defined(_CL_HAVE_WCHAR_T)
             QString retValue = QString::fromWCharArray(string);
@@ -126,6 +126,7 @@ namespace {
         #endif
     }
 }
+using namespace QtCLuceneHelpers;
 
 QT_END_NAMESPACE