From 2b81a1accd7d2519d39c0ae42caff7ff3a8c2b55 Mon Sep 17 00:00:00 2001 From: Souriya Trinh Date: Sat, 22 Jun 2024 23:30:53 +0200 Subject: [PATCH 1/2] Fix WIN32 macro usages, see: - https://github.com/ermig1979/Simd/commit/961b5e2387d99e4d2a18b9af98a4ba7e490ae366 - https://sourceforge.net/p/predef/wiki/OperatingSystems/ - https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170 - http://docwiki.embarcadero.com/RADStudio/Athens/en/Predefined_Macros - http://jdebp.info/FGA/predefined-macros-platform.html --- 3rdparty/simdlib/Simd/SimdAlignment.h | 2 +- 3rdparty/simdlib/Simd/SimdAllocator.hpp | 2 +- 3rdparty/simdlib/Simd/SimdBaseCpu.cpp | 6 +++--- 3rdparty/simdlib/Simd/SimdLib.cpp | 4 ++-- modules/core/test/math/testMath.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/3rdparty/simdlib/Simd/SimdAlignment.h b/3rdparty/simdlib/Simd/SimdAlignment.h index a0c5699a06..08f451b495 100644 --- a/3rdparty/simdlib/Simd/SimdAlignment.h +++ b/3rdparty/simdlib/Simd/SimdAlignment.h @@ -58,7 +58,7 @@ namespace Simd SIMD_INLINE size_t Alignment() { -#if defined(WIN32) +#if defined(_WIN32) return GetAlignment(); #else return ALIGNMENT; diff --git a/3rdparty/simdlib/Simd/SimdAllocator.hpp b/3rdparty/simdlib/Simd/SimdAllocator.hpp index 8ee548e5ae..e90d5520ab 100644 --- a/3rdparty/simdlib/Simd/SimdAllocator.hpp +++ b/3rdparty/simdlib/Simd/SimdAllocator.hpp @@ -125,7 +125,7 @@ namespace Simd */ static SIMD_INLINE size_t Alignment() { -#if defined(__SimdAlignment_h__) && defined(WIN32) +#if defined(__SimdAlignment_h__) && defined(_WIN32) return Simd::Alignment(); #else return SimdAlignment(); diff --git a/3rdparty/simdlib/Simd/SimdBaseCpu.cpp b/3rdparty/simdlib/Simd/SimdBaseCpu.cpp index ab0cf38d6f..53948c1400 100644 --- a/3rdparty/simdlib/Simd/SimdBaseCpu.cpp +++ b/3rdparty/simdlib/Simd/SimdBaseCpu.cpp @@ -33,7 +33,7 @@ #include #include -#if defined(_MSC_VER) +#if defined(_WIN32) #ifndef NOMINMAX #define NOMINMAX @@ -77,7 +77,7 @@ namespace Simd { #if defined(SIMD_X86_ENABLE) || defined(SIMD_X64_ENABLE) bool CheckBit(int eax, int ecx, Cpuid::Register index, Cpuid::Bit bit) { unsigned int registers[4] = { 0, 0, 0, 0 }; -#if defined(_MSC_VER) +#if defined(_WIN32) __cpuidex((int*)registers, eax, ecx); #elif (defined __GNUC__) if (__get_cpuid_max(0, NULL) < eax) @@ -124,7 +124,7 @@ namespace Simd { } #endif -#if defined(_MSC_VER) +#if defined(_WIN32) typedef SYSTEM_LOGICAL_PROCESSOR_INFORMATION Info; void GetLogicalProcessorInformation(std::vector& info) { diff --git a/3rdparty/simdlib/Simd/SimdLib.cpp b/3rdparty/simdlib/Simd/SimdLib.cpp index a70197885d..57adeb2df5 100644 --- a/3rdparty/simdlib/Simd/SimdLib.cpp +++ b/3rdparty/simdlib/Simd/SimdLib.cpp @@ -30,7 +30,7 @@ #define SIMD_LIB_CPP #endif -#if defined(WIN32) && !defined(SIMD_STATIC) +#if defined(_WIN32) && !defined(SIMD_STATIC) #define SIMD_EXPORTS #ifndef NOMINMAX @@ -50,7 +50,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved) } return TRUE; } -#endif//WIN32 +#endif//_WIN32 #include "Simd/SimdLib.h" diff --git a/modules/core/test/math/testMath.cpp b/modules/core/test/math/testMath.cpp index 23292c7aca..edd45b92d6 100644 --- a/modules/core/test/math/testMath.cpp +++ b/modules/core/test/math/testMath.cpp @@ -53,7 +53,7 @@ // 4723 : potential divide by 0 #endif -#ifdef WIN32 +#ifdef _WIN32 #ifndef NAN // https://msdn.microsoft.com/en-us/library/w22adx1s%28v=vs.120%29.aspx // http://tdistler.com/2011/03/24/how-to-define-nan-not-a-number-on-windows From 1ecda2983be766270bd28d41f7a627b9bd68b6df Mon Sep 17 00:00:00 2001 From: Souriya Trinh Date: Sat, 22 Jun 2024 23:40:44 +0200 Subject: [PATCH 2/2] Fix global usage of "WIN32" macros, see corresponding MR for info. --- modules/core/include/visp3/core/vpSerial.h | 2 +- modules/core/src/tools/serial/vpSerial.cpp | 8 ++++---- modules/robot/src/real-robot/flir-ptu/vpRobotFlirPtu.cpp | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/core/include/visp3/core/vpSerial.h b/modules/core/include/visp3/core/vpSerial.h index c961e49ca5..af5e2bd4fe 100644 --- a/modules/core/include/visp3/core/vpSerial.h +++ b/modules/core/include/visp3/core/vpSerial.h @@ -54,7 +54,7 @@ BEGIN_VISP_NAMESPACE int main() { -#ifndef WIN32 +#ifndef _WIN32 vpSerial serial("/dev/ttyUSB0"); serial.write("Hello world"); #endif diff --git a/modules/core/src/tools/serial/vpSerial.cpp b/modules/core/src/tools/serial/vpSerial.cpp index dc67b13159..1c4e2461f1 100644 --- a/modules/core/src/tools/serial/vpSerial.cpp +++ b/modules/core/src/tools/serial/vpSerial.cpp @@ -67,7 +67,7 @@ BEGIN_VISP_NAMESPACE int main() { -#ifndef WIN32 +#ifndef _WIN32 vpSerial serial("/dev/ttyUSB0"); #endif } @@ -79,7 +79,7 @@ int main() int main() { -#ifndef WIN32 +#ifndef _WIN32 vpSerial serial; serial.setPort("/dev/ttyUSB0"); serial.open(); @@ -146,7 +146,7 @@ void vpSerial::setStopbits(const stopbits_t &stopbits) { m_stopbits = stopbits; int main() { -#ifndef WIN32 +#ifndef _WIN32 vpSerial serial; serial.setPort("/dev/ttyUSB0"); serial.open(); @@ -207,7 +207,7 @@ void vpSerial::close() int main() { -#ifndef WIN32 +#ifndef _WIN32 vpSerial serial; serial.setPort("/dev/ttyUSB0"); diff --git a/modules/robot/src/real-robot/flir-ptu/vpRobotFlirPtu.cpp b/modules/robot/src/real-robot/flir-ptu/vpRobotFlirPtu.cpp index ce4e9a98e1..27b57c2a03 100644 --- a/modules/robot/src/real-robot/flir-ptu/vpRobotFlirPtu.cpp +++ b/modules/robot/src/real-robot/flir-ptu/vpRobotFlirPtu.cpp @@ -71,7 +71,7 @@ void vpRobotFlirPtu::emergencyStop(int signo) case SIGSEGV: msg << "SIGSEGV (stop due to a segmentation fault) "; break; -#ifndef WIN32 +#ifndef _WIN32 case SIGBUS: msg << "SIGBUS (stop due to a bus error) "; break; @@ -113,7 +113,7 @@ vpRobotFlirPtu::vpRobotFlirPtu() { signal(SIGINT, vpRobotFlirPtu::emergencyStop); signal(SIGSEGV, vpRobotFlirPtu::emergencyStop); -#ifndef WIN32 +#ifndef _WIN32 signal(SIGBUS, vpRobotFlirPtu::emergencyStop); signal(SIGKILL, vpRobotFlirPtu::emergencyStop); signal(SIGQUIT, vpRobotFlirPtu::emergencyStop); @@ -547,7 +547,7 @@ void vpRobotFlirPtu::connect(const std::string &portname, int baudrate) // Open a port if (ceropen(m_cer, portname.c_str(), 0)) { -#if WIN32 +#if _WIN32 throw(vpException(vpException::fatalError, "Failed to open %s: %s.", portname.c_str(), cerstrerror(m_cer, errstr, sizeof(errstr)))); #else