From 133b8d0978180e00fb79d4ce9ab26fe34ca7a333 Mon Sep 17 00:00:00 2001 From: Saran Tunyasuvunakool Date: Thu, 11 May 2023 04:54:01 -0700 Subject: [PATCH] Make MuJoCo buildable with Visual Studio 2019 update 7 and earlier. Also enable MSVC 2019 builds on GitHub Actions. Fixes #862. PiperOrigin-RevId: 531167754 Change-Id: I17687fb287c38a7f2245c6f7ba59a22b772e3a8c --- .github/workflows/build.yml | 7 +++++++ src/engine/engine_collision_driver.h | 11 +++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 616a8d81..5394c0ae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -94,6 +94,13 @@ jobs: -DMUJOCO_HARDEN:BOOL=ON tmpdir: "/tmp" - os: windows-2022 + cmake_args: >- + -DCMAKE_SYSTEM_VERSION="10.0.22621.0" + cmake_build_args: "-- -m" + tmpdir: "C:/Temp" + - os: windows-2019 + cmake_args: >- + -DCMAKE_SYSTEM_VERSION="10.0.22621.0" cmake_build_args: "-- -m" tmpdir: "C:/Temp" diff --git a/src/engine/engine_collision_driver.h b/src/engine/engine_collision_driver.h index f6152863..b062ef99 100644 --- a/src/engine/engine_collision_driver.h +++ b/src/engine/engine_collision_driver.h @@ -21,6 +21,13 @@ #ifdef __cplusplus extern "C" { +#elif !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L +// No C11 support in Visual Studio 2019 update 7 and earlier. +// However, MSVC allows C++ alignas to be used in C code, so +// we can just skip the #include . +#ifndef _MSC_VER +#error "Compiler does not support C11." +#endif #else #include #endif @@ -43,7 +50,7 @@ MJAPI int mj_collideOBB(const mjtNum aabb1[6], const mjtNum aabb2[6], const mjtNum xpos2[3], const mjtNum xmat2[9], mjtNum product[36], mjtNum offset[12], mjtByte* initialize); -// broad phase collistion detection; return list of body pairs for narrow phase +// broad phase collision detection; return list of body pairs for narrow phase int mj_broadphase(const mjModel* m, mjData* d, int* bodypair, int maxpair); // test two geoms for collision, apply filters, add to contact list @@ -51,7 +58,7 @@ int mj_broadphase(const mjModel* m, mjData* d, int* bodypair, int maxpair); void mj_collideGeoms(const mjModel* m, mjData* d, int g1, int g2, int flg_user, mjtNum usermargin); -// number of possible collisions based on fitlers and geom types +// number of possible collisions based on filters and geom types int mj_contactFilter(int contype1, int conaffinity1, int contype2, int conaffinity2);