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

cmake: Use NOMINMAX on Windows #11385

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

RytoEX
Copy link
Member

@RytoEX RytoEX commented Oct 12, 2024

Description

This PR makes a few changes.

  1. Explicitly use std::min
  2. Explicitly use std::max
  3. Set NOMINMAX as a default compile definition on Windows to prevent defining min/max macros

Motivation and Context

Want to just use STL std::min/std::max and avoid shenanigans with min/max macros.

See also:

Also needs:

Can remove the /wd4005 additions later when other changes land in the Elgato submodule to properly guard NOMINMAX.

How Has This Been Tested?

Built locally on Windows 11. Still needs built with VS for/on WoA to make sure it works.

Types of changes

  • Code cleanup (non-breaking change which makes code smaller or more readable)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@RytoEX RytoEX added the Code Cleanup Non-breaking change which makes code smaller or more readable label Oct 12, 2024
@RytoEX RytoEX requested review from derrod and PatTheMav October 12, 2024 01:24
@RytoEX RytoEX self-assigned this Oct 12, 2024
Copy link
Member

@PatTheMav PatTheMav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still two more instances of specific NOMINMAX use:

target_compile_definitions(updater PRIVATE NOMINMAX "PSAPI_VERSION=2")

target_compile_definitions(decklink PRIVATE $<$<PLATFORM_ID:Windows>:NOMINMAX>)

Copy link
Member

@derrod derrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth noting this only applies to C++ code (thanks MS) and we'll still have to deal with min()/max() macros in C code, but this will at least solve ambiguities and the related issues with the Qualcomm PR.

@RytoEX RytoEX force-pushed the use-nominmax-on-windows branch from 815416a to 6474063 Compare October 15, 2024 18:48
@RytoEX
Copy link
Member Author

RytoEX commented Oct 15, 2024

There's still two more instances of specific NOMINMAX use:

target_compile_definitions(updater PRIVATE NOMINMAX "PSAPI_VERSION=2")

target_compile_definitions(decklink PRIVATE $<$<PLATFORM_ID:Windows>:NOMINMAX>)

Removed those. Thanks.

The commits may need squashed to avoid the first two commits failing.

This prevents the Windows headers from defining min/max macros.

Use std::min and std::max.

Modifies deps, frontend, libobs-d3d11, libobs-winrt, decklink, obs-vst,
and win-dshow.
@RytoEX RytoEX force-pushed the use-nominmax-on-windows branch from 6474063 to 6ee84c7 Compare February 7, 2025 18:13
@RytoEX RytoEX added this to the OBS Studio 31.1 milestone Feb 7, 2025
@RytoEX RytoEX requested a review from PatTheMav February 7, 2025 18:16
@RytoEX RytoEX marked this pull request as ready for review February 7, 2025 18:25
@RytoEX RytoEX merged commit e471d31 into obsproject:master Feb 7, 2025
14 checks passed
@RytoEX RytoEX deleted the use-nominmax-on-windows branch February 7, 2025 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Cleanup Non-breaking change which makes code smaller or more readable Windows Affects Windows
Projects
Development

Successfully merging this pull request may close these issues.

4 participants