Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


Using __ASSERT_ALWAYS

This simple example of the use of __ASSERT_ALWAYS shows how to panic on an illegal value.

Suppose the member function F() in class CMyClass, takes a TInt argument which must always be zero or positive.

void CMyClass::F(TInt aValue)
 {
 _LIT(KMyPanicDescriptor, "My panic text");
 __ASSERT_ALWAYS(aValue >= 0,User::Panic(KMyPanicDescriptor));
 ...
 /* main body of the function */
 ...
 }

If the caller passes a value which is negative, the current thread is panicked.