Fix typos in #if and nonstandard implicit cast. #310
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Regarding the changes in math.h, it appears that
_MSC_VER
was typoed in preprocessor statements in two different ways: once as__MSV_VER
and again as__MSC_VER
(note the double underscore) which means they will be treated as 0. Combined with<
or<=
, it means that the check will be true on all compilers building for windows.The typos in math.h (and missing defined(_MSC_VER)) caused the following errors when cross-compiling with
llvm-mingw
on a Linux system:The second instance guards what appear to be fallback implementations of
roundf
andnextafter
.One concern I have is these Visual Studio 2013(?) implementations of
nextafter(float, float)
androundf(float)
are actually wildly incorrect, and specificallyroundf
was likely being used on all windows builds:nextafter(x, -1.0)
was unused except in tutorial code, but if it were used, as in tutorials/common/texture/texture2d.cpp, it would cause the texture dimensions to be multiplied by 0.9roundf(float x)
seems mostly correct for float values which are representable as a 32-bit integer, but for those which are not, will cause some form of overflow. This seems like potential for bugs.This PR will inadvertently fix these issues, by fixing the condition for the "fallback" implementations to be used. Hopefully nothing depended on the overflow mechanic of the old
roundf
implementation...Regarding the other change, the missing (void*) cast in common/sys/library.cpp is apparently a non-standard Microsoft extension, allowed only in the Microsoft-compatible setting of clang, and not by default. Using the same command line as on Windows, this implicit cast from FARPROC to void* causes the following error.
By adding
-fms-compatibility
to the command line on a clang build, it is possible to reduce this to a warning instead of an error:However, it would be preferable to solve this by performing an explicit cast to
void*
.Collectively, these two fixes allow embree to be cross compiled using llvm-mingw on Linux without any non-standard options.