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

Compilation fails on Windows due to undefined __builtin_ctz call. #1292

Closed
ix-dcourtois opened this issue Nov 6, 2020 · 1 comment
Closed

Comments

@ix-dcourtois
Copy link
Contributor

Problem

OSL (@ c7d77d8) fails to build on Windows due to PR #1276
in OSL/mask.h, line 166, __builtin_ctz is undefined on MSVC.

I fixed this with the following patch (taken from c7d77d8) but I'm not sure if this is ok.
Maybe the author of the PR (@AlexMWells) could take a look ?

diff --git a/src/include/OSL/mask.h b/src/include/OSL/mask.h
index 1580f39e..4b430224 100644
--- a/src/include/OSL/mask.h
+++ b/src/include/OSL/mask.h
@@ -162,6 +162,10 @@ public:
         if (value_width <= 32) {
 #if __INTEL_COMPILER
             return _bit_scan_forward(m_value);
+#elif (defined(_WIN32) || defined(_WIN64))
+            unsigned long index;
+            _BitScanForward(&index, m_value);
+            return static_cast<int>(index);
 #else
             return __builtin_ctz(m_value);
 #endif

Versions

  • OSL branch/version: master
  • OS: Windows
  • C++ compiler: MSVC 2017
  • LLVM version: 11.0
  • OIIO version: 2.1.xx
@lgritz
Copy link
Collaborator

lgritz commented Nov 6, 2020

Fix is already submitted: #1291

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

No branches or pull requests

2 participants