google-deepmind / mujoco_mpc

Real-time behaviour synthesis with MuJoCo, using Predictive Control
https://github.com/deepmind/mujoco_mpc
Apache License 2.0
898 stars 130 forks source link

Disable clashing min/max macros on Windows #287

Closed rkourdis closed 4 months ago

rkourdis commented 4 months ago

On Windows, including "Windows.h" defines min() and max() macros that clash with the STL functions under <algorithm>.

This causes a compilation error on Visual Studio 2022:

FAILED: mjpc/CMakeFiles/libmjpc.dir/utilities.cc.obj 

[...]

C:\[...]\mujoco_mpc\mjpc\utilities.cc(822): error C2589: '(': illegal token on right side of '::'
C:\[...]\mujoco_mpc\mjpc\utilities.cc(822): error C2062: type 'unknown-type' unexpected
C:\[...]\mujoco_mpc\mjpc\utilities.cc(822): error C2059: syntax error: ')'

Defining NOMINMAX before the include disables the definition of these macros, allowing the use of std::max() from <algorithm>.

google-cla[bot] commented 4 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

rkourdis commented 4 months ago

@nimrod-gileadi Thanks for having a look! I've just rebased to latest main and for some reason it dismissed the review - let me know if we can merge when you have time :))

thowell commented 4 months ago

@rkourdis can you update your branch so we can merge this PR?

rkourdis commented 4 months ago

@thowell Just updated the branch, thanks!