-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
exceptions are currently required #70
Comments
The |
Hmm, at least with VC++ 18, commenting out those try/catch let it compile. I haven't test with GCC, Clang, Embacadero, etc. |
GCC gives compile errors for If you want to use cppformat with the code without exception, you can create a simple wrapper for |
Another option would be to allow a simple #define to change the throw statements in C++ Format to calls to a wrapper that aborts with the error. Aside from any other arguments I might have, your proposed solution still doesn't solve the issue for C++ implementations that don't support exceptions (or support them with caveats and bugs) or for environments with extremely strict "no exceptions, period" rules. Something like a
And a user of the library can then #define their own error handler that calls into their appropriate error handling system, or override assert (which many do already for improved assert handling or platform-specific reasons). |
Should be done in 8b76e97. Thanks for the suggestion. |
cppformat cannot be compiled with exceptions disabled due to a single try/catch block with an empty catch clause.
A number of platforms and specialized applications have mandatory no-exceptions rules. Embedded apps, games, high-availability, etc. often run on platforms where exceptions are either deemed too dangerous and hard to reason about or run on memory/performance-constrained devices that can't take the code bloat hit of exceptions or even run on platforms with non-conforming C++ implementations that don't support exceptions in the first place.
The ability to disable exceptions in cppformat would be nice. It's easy enough to just comment out the one use of try/catch, but having it Just Work(tm) would be nicer.
Defines to detect exception support include
__EXCEPTIONS
on GCC/Cland and_HAS_EXCEPTIONS
on cl (VC++).The text was updated successfully, but these errors were encountered: