Skip to content
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

Fix inclusion in translation units with exceptions disabled. #196

Merged
merged 1 commit into from
May 19, 2021

Conversation

chinmaygarde
Copy link
Contributor

@chinmaygarde chinmaygarde commented May 18, 2021

If exceptions are disabled via -fno-exceptions, the use of try-catch is
disallowed by the compiler.

This patch does two things:

  • Gates the use of try-catch in one translation unit on the definition of
    INJA_NOEXCEPTION.
  • Make it such that translation units compiled with -fno-exceptions but no
    INJA_NOEXCEPTION implicitly sets INJA_NOEXCEPTION.

In the specific case of ifstream::open, setting the exceptions bits without
exceptions enabled should trip an assertion just like INJA_ABORT. The nice
message will not be present however, but that is absent when using INJA_ABORT as
well.

After this patch, inja can be successfully included without issue.

If exceptions are disabled via `-fno-exceptions` or `INJA_NOEXCEPTION`, the use
of try-catch is disallowed by the compiler.

This patch makes does two things:
* Gates the use of try-catch in one translation unit on the definition of
  `INJA_NOEXCEPTION`.
* Make it such that translation units compiled with `-fno-exceptions` but no
  `INJA_NOEXCEPTION` implicitly sets `INJA_NOEXCEPTION`.

In the specific case of `ifstream::open`, setting the exceptions bits without
exceptions enabled should trip an assertion just like INJA_ABORT. The nice
message will not be present however, but that is absent when using INJA_ABORT as
well.

After this patch, inja can be successfully included without issue.
@pantor pantor merged commit 2491980 into pantor:master May 19, 2021
@pantor
Copy link
Owner

pantor commented May 19, 2021

Thanks for fixing!

@chinmaygarde chinmaygarde deleted the fix_noexcept branch July 12, 2021 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants