Jeff
Jeff

Reputation: 135

Is there a way to enable/disable the exception handling in the C++ source file

I know C++ compiler allows to use -fexceptions and -fno-exceptions to enable and disable exception handling. Is there a way to disable or enable exception handling by just defining some preprocessor in the C++ source code file?

Upvotes: 2

Views: 4500

Answers (1)

John Zwinck
John Zwinck

Reputation: 249163

The same question was recently asked on a mailing list: http://comments.gmane.org/gmane.comp.gcc.help/48303

The answer is that you can do this:

#GCC pragma optimize "no-exceptions"

Now, whether you should do this is another matter, but suffice to say that you'd better know what you're doing if you go down this path.

Upvotes: 8

Related Questions