Comments (5)
The C++ standard states: Any pragma that is not recognized is ignored.
This means that this code is fine. I don't have MSVC, nor do I plan on paying any Windows license to use that broken and poorly designed piece of software (there are other arguments to defend that position, namely that even on Windows, you have better options both in terms of standard compliance and performance of the generated code -- e.g. clang). I test that it works on Windows & MSVC using GitHub CI, but that's it. I don't have more time to invest with it, particularly if the problem is that you turned on the option to change warnings as errors. I already compile with -Wextra -Wall -pedantic
on Linux, anything that pops up other than that is mostly junk coming from MSVC.
Want to fix it? Here are your options:
- Write a PR. Hint: MSVC has a non-standard pragma called
fp_contract
that does the same thing, or claims it does. I'll review your PR quickly and you can see if it works on other platforms with the integrated CI on GitHub, so you don't have to install a VM or any other operating system to test your fix. - Turn off the option to emit warnings as errors in MSVC. Warnings will still be there. You can still fix them. They're just not errors.
- Use clang. For the reasons mentioned above, you'll get a significant performance boost out of that (plus support for OpenMP 3.0 which is from 2008, still not supported to this day in MSVC).
from bvh.
I started looking at this but I run into a bit of an issue:
On my current incomplete attempt Visual Studio 2022 says:
bvh/utilities.hpp(42,17): warning C4177: #pragma 'fp_contract' should only be used at global scope or namespace scope
Meanwhile https://en.cppreference.com/w/cpp/preprocessor/impl says:
The behavior of the program is undefined if any of the three pragmas above appear in any context other than outside all external declarations or preceding all explicit declarations and statements inside a compound statement.
Does that mean that pragma STDC
must precede function definitions? Function definition is declaration, right? If so, that would kind of match with what Visual Studio 2022 says, and the pragma should be relocated. The functions could be placed into a dedicated namespace, for example.
Edit: I've updated my pull request with a commit that uses a dedicated namespace for the pragma.
from bvh.
Note that using #pragma STDC FP_CONTRACT ON
the way the library does it is fine, as it is inside a compound statement (block) and appears before anything else (except conditional preprocessor directives). The documentation on Microsoft's webpage regarding the scope and meaning of fp_contract
is lacking and it's unclear where the legal places for it are (but anyway, since it is non-standard, it can appear everywhere MSVC accepts it).
from bvh.
This message tells something about the scope for MSVC:
#pragma 'fp_contract' should only be used at global scope or namespace scope
This is the motivation to use namespace. I am updating the PR so that namespace is only used with MSVC.
from bvh.
This should have been fixed by commit 5841efb.
from bvh.
Related Issues (20)
- Two questions: MB and primitive splitting HOT 1
- raw, bvh node data to upload to the gpu HOT 1
- `build()` in debug build of v2 feels slower than v1 HOT 2
- Recovering "split axis" from MiniTreeBuilder HOT 1
- Face culling options? HOT 1
- Your code is building fine on MSYS2 MINGW64 HOT 1
- Two tests need pthread to compile on linux HOT 2
- Library does not handle rays parallel to axes HOT 5
- Identifiers near and far in bvh.h cause issues when precompiled headers are used HOT 3
- config.min_leaf_size > 1 Leads to assertion failure HOT 1
- What is the use case? is it slower than embree? HOT 1
- Cancel build +progress monitor HOT 4
- Consider adding to vcpkg HOT 1
- Ability to re-use BVH allocations? HOT 1
- Adding and Removing elements HOT 1
- Optimize node index serialization HOT 1
- Clarify what primitive data leaf nodes actually store HOT 1
- Potential bug in traversal functions HOT 1
- Possible stale pointer usage in extract_bvh()? HOT 4
- Sweep SAH builder HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bvh.