Assertions

Overview

CryAssert is a specialization of the standard ‘assert’ function – allowing developers to test whether bad or unexpected paths in the code occur.

CRY_ASSERT macros

Assertions can be performed with the CRY_ASSERT and CRY_ASSERT_MESSAGE macros. As an example, if we do not expect a pointer to be null, we could use:

CRY_ASSERT(pPtr != nullptr);

If pPtr is then nullptr when the code executes and asserts are enabled, a pop-up will appear to notify the developer of this issue. Note that this is only triggered when the 'sys_asserts' CVar is set to a non-zero value.

Conclusion

This concludes the article on CryAssert. You may be interested in: