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

Fix SDL_LEAN_AND_MEAN logic #11400

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

Lzard
Copy link
Contributor

@Lzard Lzard commented Nov 3, 2024

Currently, config flag macros depending on SDL_LEAN_AND_MEAN are always defined, regardless of its value, and only their definedness is checked, not their own values. Those changes fixes this.

See 387774a
Fixes #11344


While looking for other issues similar to this, I noticed:

  • Some config flag macros are conditionally defined, but may still not be true, e.g.:
    #if HAVE_WINAPIFAMILY_H
    #include <winapifamily.h>
    #define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP))
    #else
    #define WINAPI_FAMILY_WINRT 0
    #endif /* HAVE_WINAPIFAMILY_H */
    #if HAVE_WINAPIFAMILY_H && HAVE_WINAPIFAMILY_H
    #define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
    #else
    #define SDL_WINAPI_FAMILY_PHONE 0
    #endif
  • Third-parties sometimes always define the config flag, but either as true or false, e.g. the OpenGL/Vulkan headers, or even compiler flags:
    /* Fix building with older SDKs that don't define these
    See this for more information:
    https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets
    */
    #ifndef TARGET_OS_MACCATALYST
    #define TARGET_OS_MACCATALYST 0
    #endif
    #ifndef TARGET_OS_IOS
    #define TARGET_OS_IOS 0
    #endif
    #ifndef TARGET_OS_IPHONE
    #define TARGET_OS_IPHONE 0
    #endif
    #ifndef TARGET_OS_TV
    #define TARGET_OS_TV 0
    #endif
    #ifndef TARGET_OS_SIMULATOR
    #define TARGET_OS_SIMULATOR 0
    #endif
    #ifndef TARGET_OS_VISION
    #define TARGET_OS_VISION 0
    #endif

It might be better to always check that config flag macros are defined and true.

Lzard added 2 commits November 3, 2024 11:27
I am confused by the "You have to manually edit this file" comment. Does it mean that it is expected to manually remove the previous `#define SDL_LEAN_AND_MEAN 0` ?
In any case I put this part of the change in a separate commit so that it can easily be reverted.
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.

Broken preprocessor logic for SDL_LEAN_AND_MEAN (and possibly more?)
1 participant