I am writing a C ++ library, and I would like to make my APIs exceptions for invalid parameters, but rely on statements instead when the code is compiled with -fno-exceptions .
Is there any way to detect at compile time if I am allowed to use exception handling? Please note that I write the library for headers only, so I donโt have the configure phase and I donโt have access to the build system to just define a macro on the command line (and I donโt want to add a burden to the user).
Since the Standard does not have the concept of "-fno-exceptions", of course, the solution may be compiler dependent. In this case, I'm interested in solutions that work with both g ++ and clang ++, other compilers are not important for this project.
Thank you very much
source share