-
Notifications
You must be signed in to change notification settings - Fork 98
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
Make exceptions optional #170
Conversation
Amazing! |
@pca006132 I'm still trying to figure out why I'm getting a seg fault in the boolean when I have exceptions turned off. I suspect my macros are misbehaving. I also saw this in Google's C++ style guide. They don't like macros in header files, which is exactly how I've been doing my asserts. I hadn't considered that would escape into our public API. Can you think of a better way? |
Okay, I think I've made sure our |
Do you mean when the assertion is evaluated to false (which will throw an exception when exception is enabled), the program is aborted? When exception is disabled, throw is not a nop, but calls Sorry I have been relatively busy recently, I will try to find some time to look into this. |
#define ASSERT(condition, EX, msg) \ | ||
Assert<EX>(condition, __FILE__, __LINE__, #condition, msg); | ||
#else | ||
#define ASSERT(condition, EX, msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pca006132 Replying to you here to give context. When MANIFOLD_DEBUG
is not defined, the ASSERT
macro (which replaced ALWAYS_ASSERT
) should compile out completely so there are no throw
statements left. However, it now seg faults, so I think my macro is expanding in a way I don't expect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, I found the problem. I had a side-effect inside one of my ASSERT
calls 🙄
Codecov Report
@@ Coverage Diff @@
## master #170 +/- ##
==========================================
+ Coverage 93.91% 95.88% +1.97%
==========================================
Files 30 30
Lines 2793 2626 -167
==========================================
- Hits 2623 2518 -105
+ Misses 170 108 -62
Continue to review full report at Codecov.
|
Make exceptions optional
Fixes #141
I've introduced a compiler flag:
MANIFOLD_DEBUG
that enables exceptions, as well as error and info printing. It is off by default, which means not only are the exceptions compiled out, but it also keepsiostream
and such from being included anywhere. This is to help remind us to hide messages behind this flag, as it will fail to compile otherwise.I also added
ManifoldParams()
, which allows us to control the verbosity of the Boolean operations at runtime (assuming our debug flag is set). I chose to add a new flag instead of usingNDEBUG
because that flag does not play well with Thrust and makes things run too slowly.I've also changed the constructors that take an input
Mesh
to return an emptyManifold
if the input data is bad. I also addedStatus()
to the API to return an enum of the problem with the inputMesh
if the result was empty. I also replaced some other small user-input asserts with data sanitation so that the program doesn't have to abort.I also added a bunch of tests about input validation and fixed a few bugs those revealed.