开发者

g++, cost of exceptions when I don't use exceptions

开发者 https://www.devze.com 2022-12-27 04:49 出处:网络
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 lib

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消