Sunday, March 31, 2019

software engineering - Throwing Exceptions in C++ game DLL's? Pros and Cons


What are the pros and cons of using Exceptions in C++ in relation to game development.


Google style guide says that they don't use Exceptions for a variety of reasons. Are the same reasons pertinent towards game development?



We do not use C++ exceptions... - google-styleguide.googlecode.com




Some issues to think about.



  • How it pertains to the development of a libraries used through multiple projects.

  • How does it affect unit testing, integration testing, etc?

  • What does it do to using third party libraries.



Answer



There are also some nasty consequences for using exceptions in C++ if you don't know all the details of how they work. Since many games are written in C++ this may be a factor.


For example, in C++ throwing an exception in a destructor can have serious consequences. It can cause all kinds of undefined behavior and crashes, because you can get trapped in a situation where you have more than one active exception in flight. (See Item #8 of Effective C++ for more info on this.)



No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...