From d61815a94dcb2b0fba31b598ac113038c1a0d45e Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Wed, 5 Feb 2025 16:33:37 -0500 Subject: [PATCH] Use platform preprocesor defines Instead of using CMake to check the platform and then set a target compile definition to indicate the platform, just directly check the platform just directly check the platform by checking known platform defines. --- CMakeLists.txt | 6 ------ Library/EGAVResult.cpp | 8 ++++---- Library/EGAVResult.h | 6 +++--- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a519525..5f0149d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,9 +56,3 @@ add_executable (EGAVHIDSample target_include_directories(EGAVHIDSample PRIVATE ${FRAMEWORK_FOLDER}) target_compile_definitions(EGAVHIDSample PUBLIC EGAV_API) - -if(WIN32) - target_compile_definitions(EGAVHIDSample PUBLIC _UP_WINDOWS=1) -elseif(APPLE) - target_compile_definitions(EGAVHIDSample PUBLIC _UP_MAC=1) -endif() \ No newline at end of file diff --git a/Library/EGAVResult.cpp b/Library/EGAVResult.cpp index 21835ba..1e03e89 100644 --- a/Library/EGAVResult.cpp +++ b/Library/EGAVResult.cpp @@ -31,7 +31,7 @@ SOFTWARE. //============================================================================== #include "EGAVResult.h" -#if _UP_WINDOWS +#if defined(_WIN32) #include // for HRESULT #endif @@ -51,7 +51,7 @@ EGAVResult::EGAVResult(EGAVResultCustomType inCustomResultType, int64_t inCustom mCustomResultCode = inCustomResultCode; } -#if _UP_WINDOWS +#if defined(_WIN32) void EGAVResult::InitWithHresult(HRESULT hr) { mResultCode = ErrCustom; @@ -77,10 +77,10 @@ bool EGAVResult::Succeeded() const { switch (mCustomResultType) { -#if _UP_WINDOWS +#if defined(_WIN32) case EGAVResultCustomType::Hresult: return SUCCEEDED(mCustomResultCode); case EGAVResultCustomType::WinError: return (mCustomResultCode == ERROR_SUCCESS) ? true : false; -#elif _UP_MAC +#elif defined(__APPLE__) case EGAVResultCustomType::Mac: return (mCustomResultCode == 0) ? true : false; #endif case EGAVResultCustomType::MainConcept: diff --git a/Library/EGAVResult.h b/Library/EGAVResult.h index 5017976..7409cb9 100644 --- a/Library/EGAVResult.h +++ b/Library/EGAVResult.h @@ -38,7 +38,7 @@ SOFTWARE. //------------------------------------------------------------------------------ #include -#if _UP_WINDOWS +#if defined(_WIN32) // FMB NOTE: For some strange reason must be before . // This is only necessary because contents of are required in other code files. // However, if is include somewhere it must be guaranteded that was never include before. @@ -50,7 +50,7 @@ SOFTWARE. //#include "EGAVFeatures.h" // for EGAV_API -#define EVH_AVOID_UNNEEDED_COPY_CONSTRUCTORS (!_UP_WINDOWS) //!< 0 - explicit copy constructors: required for .NET frontends connected via SWIG e.g. 4KCU and EVH Test App +#define EVH_AVOID_UNNEEDED_COPY_CONSTRUCTORS (!defined(_WIN32)) //!< 0 - explicit copy constructors: required for .NET frontends connected via SWIG e.g. 4KCU and EVH Test App //!< 1 - to avoid "warning: definition of implicit copy constructor for different classes e.g. //! 'EGAVAudioSampleType' is deprecated because it has a user-declared copy assignment operator [-Wdeprecated-copy]" @@ -141,7 +141,7 @@ class /*EGAV_API*/ EGAVResult //------------------------------------------------------------------------------ // Initialization //------------------------------------------------------------------------------ -#if _UP_WINDOWS +#if defined(_WIN32) //! Init with HRESULT (EGAVResultCustomType::Hresult) void InitWithHresult(HRESULT hr);