Hi, thanks for building OpenMesh!
I just built OpenMesh using ClangCL 19.1.5 on Windows and only encountered one problem. The symptom was strange - deep inside Microsoft header file <Unknwnbase.h>, it complained about core Windows API functions QueryInterface and QueryService not being resolvable, as _GUID was forward declared but not defined.
The problem is Timer.cc #includes several system headers from within the OpenMesh::Utils namespace, which generally a discouraged practice and likely just an oversight. The fix is to open and close the namespace in each #if branch, so the #include statements occur at file scope, outside of any namespace.
I'm on a slightly older version of OpenMesh but if the following patch doesn't apply cleanly, the general point should be clear.
Thanks again for maintaining OpenMesh!
-- Conrad
diff --git "a/src/OpenMesh/Tools/Utils/Timer.cc" "b/src/OpenMesh/Tools/Utils/Timer.cc"
index e3fca04b..715bc856 100644
--- "a/src/OpenMesh/Tools/Utils/Timer.cc"
+++ "b/src/OpenMesh/Tools/Utils/Timer.cc"
@@ -80,14 +80,19 @@ public:
virtual double seconds(void) const = 0;
};
+
+} // END_NS_UTILS
+} // END_NS_OPENMESH
+
// compiler and os dependent implementation
// ------------------------------------------------------------- windows 32 ----
#if defined(WIN32) && (defined(_MSC_VER) || defined(__INTEL_COMPILER) || defined (__MINGW32__) )
-#ifndef DOXY_IGNORE_THIS
#include <windows.h>
-#endif
+
+namespace OpenMesh {
+namespace Utils {
class TimerImplWin32 : public TimerImpl
{
@@ -146,12 +151,16 @@ double TimerImplWin32::seconds(void) const
return (double)count_.QuadPart/(double)freq_.QuadPart;
}
+} // END_NS_UTILS
+} // END_NS_OPENMESH
+
// ------------------------------------------------------------- posix time ----
#elif defined(__GNUC__) && defined(__POSIX__)
-#ifndef DOXY_IGNORE_THIS
# include <time.h>
-#endif
+
+namespace OpenMesh {
+namespace Utils {
template <clockid_t N>
class TimerImplPosix : public TimerImpl
@@ -184,6 +193,9 @@ protected:
timespec start_;
};
+} // END_NS_UTILS
+} // END_NS_OPENMESH
+
// ----------------------------------------------------------- gettimeofday ----
#elif (defined(__GNUC__) && !defined(__FreeBSD__) || (defined(__INTEL_COMPILER) && !defined(WIN32))) && !defined(__MINGW32__)
@@ -191,6 +203,9 @@ protected:
# include <sys/resource.h>
# include <unistd.h>
+namespace OpenMesh {
+namespace Utils {
+
class TimerImplGToD: public TimerImpl
{
public:
@@ -223,11 +238,16 @@ private:
double seconds_;
};
+} // END_NS_UTILS
+} // END_NS_OPENMESH
#else // ---------------------------------------- standard implementation ----
#include <time.h>
+namespace OpenMesh {
+namespace Utils {
+
static const unsigned long clockticks = CLOCKS_PER_SEC;
class TimerImplStd : public TimerImpl
@@ -254,10 +274,16 @@ void TimerImplStd::stop(void)
count_ += stop_-start_;
}
+} // END_NS_UTILS
+} // END_NS_OPENMESH
+
#endif
// ----------------------------------------------------------------- Timer ----
+namespace OpenMesh {
+namespace Utils {
+
Timer::Timer(void) :
state_(Stopped)
{
@@ -433,7 +459,6 @@ std::string Timer::as_string(double seconds, Timer::Format format)
return string;
}
-// ============================================================================
} // END_NS_UTILS
} // END_NS_OPENMESH
// ----------------------------------------------------------------------------