Переглянути джерело

Fixed duplicated symbol error due to definition in .h file, issue #325.

Sascha Zelzer 12 роки тому
батько
коміт
485f7dbfa2

+ 2 - 2
Libs/Core/CMakeLists.txt

@@ -52,7 +52,7 @@ set(KIT_SRCS
   ctkErrorLogStreamMessageHandler.h
   ctkException.cpp
   ctkException.h
-  ctkHighPrecisionTimer.h
+  ctkHighPrecisionTimer.cpp
   ctkLogger.cpp
   ctkLogger.h
   ctkHistogram.cpp
@@ -150,7 +150,7 @@ endif()
 # Testing
 if(BUILD_TESTING)
   add_subdirectory(Testing)
-  
+
   # Compile source code snippets
   add_subdirectory(Documentation/Snippets)
 endif()

+ 24 - 0
Libs/Core/ctkHighPrecisionTimer.cpp

@@ -0,0 +1,24 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#include "ctkHighPrecisionTimer.h"
+
+double ctkHighPrecisionTimer::timeConvert = 0.0;

+ 3 - 3
Libs/Core/ctkHighPrecisionTimer.h

@@ -72,10 +72,12 @@ public:
 
 private:
 
+  // only used on MacOS, but needs to be defined in the .cpp file
+  static double timeConvert;
+
 #ifdef _ctk_use_high_precision_timer_fallback
   QTime startTime;
 #elif defined(Q_OS_MAC)
-  static double timeConvert;
   quint64 startTime;
 #elif defined(Q_OS_UNIX)
   timespec startTime;
@@ -109,8 +111,6 @@ inline qint64 ctkHighPrecisionTimer::elapsedMicro()
 
 #elif defined(Q_OS_MAC)
 
-double ctkHighPrecisionTimer::timeConvert = 0.0;
-
 inline ctkHighPrecisionTimer::ctkHighPrecisionTimer()
 : startTime(0)
 {