g++, cost of exceptions when I don't use exceptions
I've some C++ projects, which does not use exception handling.
What are the benefits 开发者_JAVA技巧of adding -fno-exceptions
, or does gcc figure out itself that I don't use exceptions(nor any libraries that uses exceptions) ?
Probably minimal - the cost of an exception is mostly incurred if an exception is actually thrown. However, as usual the answer is to try it out and time it, which in this case would seem to be trivially easy. There are quite afew existing questions on this subject, such as How much footprint does C++ exception handling add.
The main difference is likely to be more in the size of the generated code than the speed of execution. You can obviously test it out to see what difference it makes, but if your interest is primarily in execution speed it probably won't make enough difference to notice or care about.
精彩评论