• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: When GCC does not provide __cpp_lib_uncaught_exceptions feature?

Resolved: When GCC does not provide __cpp_lib_uncaught_exceptions feature?

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

Following piece of code does not work right on Alpine Linux:
Source
Error:
It looks like GCC does not provide __cpp_lib_uncaught_exceptions feature. Why this could happen?

Answer:

I see a few issues with your code:
  1. __cpp_lib_uncaught_exceptions is only documented to be defined (when applicable) if you’ve #include-ed <version> or <exception>; you’ve included neither. Add #include <exceptions> above that feature test somewhere, and it should work.

  2. Your code as written will redefine uncaught_exceptions() in every compilation unit that includes it when the macro is not defined, because you made the definition in a header and did not make it inline, static or both, so every .cpp file including your header ends up getting its own exportable definition. Without the necessary headers included in your header, whether that feature test macro is defined will depend on whether each .cpp file includes <exception>/<version>, and whether it does so before or after including your header. If they aren’t uniform, some files could get your header’s definition, while others get the built-in definition.


If you have better answer, please add a comment about this, thank you!

c++ gcc linux
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Shopware 400 Status Error “This value is too long. It should have 255 character or less.” When I Try Updating Database Table

01/04/2023

Resolved: Using AWK to count multiple patterns in a file

01/04/2023

Resolved: significance letter above bar graphic in wrong order

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.