-
Notifications
You must be signed in to change notification settings - Fork 261
cpp2 compiles and run without exceptions and rtti #187
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
Conversation
#if defined CPP2_THROW | ||
#error "Do not redefine CPP2_THROW when using cpp2 with exceptions enabled." | ||
#endif | ||
#define CPP2_THROW(DESC,EXCEPTION) throw EXCEPTION |
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.
DESC & EXCEPTION are separated because #EXCEPTION only work for literals.
Thanks for your pull request! It looks like this may be your first contribution to cppfront. Before I can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). I think I sent it a few days ago, but it appears to have not been deliverable so please send me email to coordinate... thanks. |
e1988a9
to
f3eb30c
Compare
Rebased on main. |
Thanks, I appreciate this input and suggestion. How will the I'm generally sympathetic to the costs of EH and that a lot of projects disable it, and in Cpp2 I do aim to eventually implement value-based exceptions (P0709). And I'm supportive of efforts to make RTTI costs better, especially on Windows. But I'm not sure whether I can yet take the dependency on running in environments that don't support EH and RTTI. For example, IIUC the I do appreciate this and I do understand the prevalence of environments that disable EH and RTTI. I'm just not sure I'm yet in a state where I can support compatibility with those environments...? Perhaps a better solution than I'll think about this some more. Thanks for the input and the food for thought. |
…out exceptions and/or rtti turned on
f3eb30c
to
ec90d5b
Compare
It wont, the change I made is just to make the code compile. That code doesn't use RTTI and exceptions are disabled in our case on wasm targets for the web (compiled with emscripten) because it adds about ~10-20% to the wasm output and it runs a bit slower even though the code doesn't use it. A chunk of our code and nice to have features of our libraries are also disabled on wasm to keep the final wasm output as small as possible since download size is a very significant factor when we release the application. At the end of the day if the language is so much better with those features that cost might be acceptable, but in the case of Cpp1 its just not. This could change with Cpp2, but atm trying out bits of cpp2 in various places its simpler if it supports a no-rtti/no-exceptions mode in our case. |
OK, after thinking on this more I've merged this via another commit doing mostly what you're suggesting, and surface the option as a compiler flag:
@prenaux Would you please give this a try in your WASM environment, and let me know if it addresses your needs? |
Some of my code disables exceptions & rtti. This PR makes minor changes in cpp2util.h to allow cpp2 compiled code to compile & run with both exceptions and RTTI disabled.