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

Fixed unknown pragma warnings for _BitScanReverse. #259

Merged
merged 2 commits into from
Jan 8, 2016

Conversation

mwinterb
Copy link
Contributor

@mwinterb mwinterb commented Jan 6, 2016

Changed to only define the MSVC implementations for clz and clzll if the builtins are not available to avoid warnings about an unknown #pragma for "intrinsic".

Changed to only define the MSVC implementations for clz and clzll if the builtins are not available to avoid warnings about an unknown #pragma for "intrinsic".
// otherwise support __builtin_clz and __builtin_clzll, so
// only define FMT_BUILTIN_CLZ using the MSVC intrinsics
// if the clz and clzll builtins are not available.
# if !defined(FMT_BUILTIN_CLZ)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not merge this #ifdef with _MSC_VER check above for simplicity and to avoid intrin.h inclusion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I originally had, but I was being overly paranoid and worried about "what if there's a compiler with __builtin_clz support, but not __builtin_clzll, or the other way around?" and #if defined(_MSC_VER) && (!defined(FMT_BUILTIN_CLZ) || !defined(FMT_BUILTIN_CLZLL)) was difficult for me to read and validate that it was correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose I could also write a "test" in util-test.cc that emits a #error if FMT_BUILTIN_CLZ and FMT_BUILTIN_CLZLL macros are not defined in the cases where it's obvious they should be supported, but avoiding warnings makes it cumbersome to see that in the real code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safe to just check for FMT_BUILTIN_CLZLL. FMT_BUILTIN_CLZ is just an optimization and although I wouldn't expect compilers to provide one and not the other, it shouldn't be critical.

@vitaut
Copy link
Contributor

vitaut commented Jan 7, 2016

Thanks for another useful PR. Mostly looks good, just one minor comment above.

…able.

This is mainly just to avoid including intrin.h unnecessarily.
vitaut added a commit that referenced this pull request Jan 8, 2016
Fixed unknown pragma warnings for _BitScanReverse.
@vitaut vitaut merged commit 979e70f into fmtlib:master Jan 8, 2016
@vitaut
Copy link
Contributor

vitaut commented Jan 8, 2016

Thanks!

@mwinterb mwinterb deleted the unknown_pragma_bsr branch January 10, 2016 02:38
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

Successfully merging this pull request may close these issues.

2 participants