Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed unnecessary _WIN64 conditional checks #1559

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

fpagliughi
Copy link
Contributor

@fpagliughi fpagliughi commented Jan 9, 2025

Minor nit to start some cleanup....

The _WIN64 preprocessor macro is always defined by the Microsoft compiler when _WIN32 is defined. So you don't need to check if one or the other is defined. You can just check for _WIN32.

#if defined(_WIN32)
    // Windows code (32 or 64-bit)
#else
    // Non-windows code (Linux, macOS, etc)
#endif

If you need code specific for 32-bit vs 64-bit, you need need to check for _WIN64 first/else, or nest it, like:

#if defined(_WIN32)
    #if defined(_WIN64)
        // Windows 64-bit code
    #else
        // Windows 32-bit code
    #endif
#else
    // Non-windows code (Linux, macOS, etc)
#endif

but we're not making that distinction here. To just check if we're on Windows, checking for _WIN32 is sufficient.

From the Microsoft documentation:

  • _WIN32 Defined as 1 when the compilation target is 32-bit ARM, 64-bit ARM, x86, or x64. Otherwise, undefined.

  • _WIN64 Defined as 1 when the compilation target is 64-bit ARM or x64. Otherwise, undefined.

https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170

src/MQTTAsync.c Outdated Show resolved Hide resolved
- Fixed some conditional compilation using (WIN32) to (_WIN32)
@fpagliughi fpagliughi force-pushed the remove-unnecessary-win64 branch from 3b8579a to 1bb2e69 Compare January 9, 2025 21:10
@fpagliughi fpagliughi changed the title - Removed unnecessary _WIN64 conditional checks Removed unnecessary _WIN64 conditional checks Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants