Topic : Robust Programs - Assertions
Author : John Morris
Page : << Previous 2  
Go to page :

are robust and self-checking in the test and verify stage, yet lean and efficient for production. assert simply uses capabilities of the C pre-processor, so it would be possible to synthesise your own version which has the same effect, it is strongly recommended that for routine applications, you use the standard method: it's in the standard and therefore should be portable and a software engineer will immediately understand your code.

It is, of course, possible to design more elaborate schemes which, for example, can include or exclude large sets of debugging code which can be enabled or disabled at will in the testing phase in order to track down particular errors. The C pre-processor is a marvellous toy and it's possible to make such elaborate schemes that even a good hacker will need a day or two to appreciate them fully! My plea to you is to remember always:

Simplicity is marvellous!
A really good system does what you want and can be understood by the average C programmer in 10 minutes!

Key terms

A statement about the state of objects within a program at some point in the execution of the program. Usually this will be written as a boolean expression involving objects in the program which should be TRUE at that point in the program.
NULL is a constant defined in <stdio.h> which is a null pointer, ie a pointer to a zero address. It is usually defined as (void *)0 - a pointer to a void which has the value 0. As a void * pointer, it will match any any pointer without causing the compiler to emit a warning.
The pre-conditions of a function are states of a program which should exist before a function is called or invoked. Correct performance of the function depends on the pre-conditions being met. Pre-conditions should be considered a part of the formal specification of every function.
Graphical User Interfaces (GUIs) allow users to directly interact with objects such as menus, buttons and icons on a computer screen. They originated in a project of Xerox-PARC and became widely used when the Apple Macintosh provided a GUI operating system.

Page : << Previous 2