Instead of calling exit(1), teach triangle to throw exception#1800
Instead of calling exit(1), teach triangle to throw exception#1800alecjacobson merged 1 commit intomainfrom
exit(1), teach triangle to throw exception#1800Conversation
|
Hmm this is a really murky modification. At this point we might as well modify our version of triangle to compile with .cpp and throw an exception directly. Providing an incomplete "triangle" lib where |
Happy to accept a PR that does that change instead. This was meant to be a minimal change to libigl/triangle. I don't know what converting the whole thing to .cpp would entail (maybe that's what qnzhou/trianglelite; but it still just downloads the original triangle with this exit problem). I'm not sure I 100% understand the A/B scenario. In this scenario, some component of the project is using triangle via libigl but not linking to libigl? Is this a scenario worth worrying about?
This aspect should be fixed now. |
Actually you don't need to convert the whole file to .cpp. Simply add a file
Yes, this happens all the time. If we put aside the It is a small change to add the file |
include/igl/triangle/triexit.cpp
Outdated
| { | ||
| void triexit(int status) | ||
| { | ||
| throw std::runtime_error("triexit("+std::to_string(status)+")"); |
There was a problem hiding this comment.
Btw I am not sure what happens when you put extern "C" around a code block and then throw a C++ exception inside...
There was a problem hiding this comment.
This seems to be undefined behavior:
https://stackoverflow.com/questions/15845681/can-c-functions-marked-as-extern-c-throw
|
Oh and yes |
|
Btw I just tried renaming |
|
Let's do it! That seems better all around.
…On Sun, May 2, 2021, 3:20 PM Jérémie Dumas ***@***.***> wrote:
Btw I just tried renaming triangle.c into triangle.cpp it compiles
perfectly fine out of the box, so to avoid the undefined behavior of
throwing exceptions across C functions, I would rather switch triangle to
.cpp directly.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1800 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARDJGMOHEJD2BTKGEVKXCDTLWQYZANCNFSM437UFPHA>
.
|
0c70388 to
a0f9495
Compare
|
Alright PR updated -- changes are much smaller now. Feel free to merge. |
Switch triangle version to one where it's possible to customize the function
triexitwhich is called when triangle fails.Meanwhile, in libigl provide this custom implementation to throw a
std::runtime_exception.(Note, this change is unrelated to switching to https://github.com/qnzhou/trianglelite . That may be a good idea in the future but doesn't immediately solve the problem of triangle calling exit)