Skip to content

Commit dcd0285

Browse files
Allow combined version macro in preprocessor (#2270)
Fixes #2269
1 parent b20f89f commit dcd0285

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

source/MaterialXCore/Library.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
#include <MaterialXCore/Generated.h>
2323

24-
#define MATERIALX_GENERATE_INDEX(major, minor, build) \
25-
((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(build)))
24+
#define MATERIALX_GENERATE_INDEX(major, minor, build) (((major) << 22U) | ((minor) << 12U) | (build))
25+
2626
#define MATERIALX_VERSION_INDEX \
2727
MATERIALX_GENERATE_INDEX(MATERIALX_MAJOR_VERSION, MATERIALX_MINOR_VERSION, MATERIALX_BUILD_VERSION)
2828

source/MaterialXTest/MaterialXCore/CoreUtil.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@ namespace mx = MaterialX;
1212

1313
TEST_CASE("Version comparison", "[coreutil]")
1414
{
15-
// Test for version comparison
15+
// Test for version comparison (C++ context)
1616
REQUIRE(MATERIALX_VERSION_INDEX > MATERIALX_GENERATE_INDEX(1, 38, 8));
17+
18+
// Test for version comparison (preprocessor context)
19+
#if MATERIALX_VERSION_INDEX > MATERIALX_GENERATE_INDEX(1, 38, 8)
20+
REQUIRE(true);
21+
#else
22+
REQUIRE(false);
23+
#endif
1724
}
1825

1926
TEST_CASE("String utilities", "[coreutil]")

0 commit comments

Comments
 (0)