-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[rcore] Fix for undeclared function _BitScanReverse on Windows
#5367
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
Conversation
|
@ChrisGrams I don't understand, this library is required to address a Clang issue but it's checking for a Visual Studio define ( static int
sinfl_bsr(unsigned n) {
#ifdef _MSC_VER
unsigned long uln = 0;
_BitScanReverse(&uln, n);
return (int)(uln);
#else // defined(__GNUC__) || defined(__clang__) || defined(__TINYC__)
return 31 - __builtin_clz(n);
#endif
}I personally prefer to minimize libraries addition but, in any case, this change should be reported to https://github.com/vurtun/lib, to avoid beeing overriden on update. Also comment should not make referencee to |
_BitScanReverse on Windows
|
@raysan5 If one uses the version of Clang installed with Visual Studio, _MSC_VER is also defined. In your code snippet, the compiler doesn't get to __builtin_clz() because _MSC_VER is defined. The intrin.h header is not included, so we get the undefined function error. You are of course correct to point out that it's best not to modify external code. I apologize for the poorly placed patch. Perhaps it would be better to place this in the rcore.c file? |
|
@ChrisGrams It should be reported to original author, not patched on raylib side. |
|
@raysan5 I agree and I did submit a PR there as well. I don't use GitHub very often, and I probably went about this the wrong way for which I apologize. My purpose was simply to notify you of a minor problem and give you a workable solution. I do appreciate your time and patience, looking over this small patch. Thank you. |
|
@Raysan unfortunately LLVM on windows defines Replacing those Lines 201 to 206 in 84737a9
Lines 174 to 179 in 84737a9
@ChrisGrams there is already a PR about the same issue with Alternatively you can try to compile with |
|
@hanaxars Thanks for the proposed solution, just implemented it to avoid including an additional library in a specific case it shouldn't be required. |
This PR fixes a regression introduced in commit 0b4815b (Nov 9).
After this commit,
rcore.cno longer includedmsf_gif.h, which previouslypulled in
<intrin.h>under_MSC_VER. As a result, Clang+C99 builds onWindows fail with
_BitScanReverseundeclared.Fix
Add explicit
#include <intrin.h>under_MSC_VERinsdefl.handsinfl.h.Tested
-std=c99 -Werror=implicit-function-declaration