GEOS SDK TechDocs
|
|
5 The Error-Checking Version
|
5.2 Special EC Routines
When compiling your code, you can include certain extra lines in either the EC version or the non-EC version of your program. For example, during debugging you want your program to check the validity of each memory handle before locking the memory block; for the final version of your program, however, you don't want this validity check because it slows down your program. You can easily add a few instructions that will be compiled only into the EC version.
GEOS provides five macros, listed below, for version-specific instructions. These macros must be treated as statements; they may not be used in expressions.
FatalError()
with a specified error code. The call to
FatalError()
will not be included in the non-EC version.
FatalError()
will be called. If the condition is met,
FatalError()
will be called.
ECCheckBounds()
routine. If the pointer is out of bounds,
ECCheckBounds()
will call
FatalError()
. This macro may only add the bounds check to the EC version.An example of use of these macros is shown in EC Macros .
/* This code display shows only the usage of these macros; assume that each * line shown below exists within a particular function or method. */
/* The EC macro adds a line of code to the EC version. Its format is
* EC(line) where line is the line of code to be added.
* Note that the NEC macro is similar. */
EC( @call MyErrorDialogBox::MSG_MY_ERR_PRINT_ERROR(); )
NEC( @call MyErrorDialogBox::MSG_MY_ERR_PRINT_NO_ERROR(); )
/* The EC_ERROR macro adds a call to FatalError() to the EC version. Its format is
* EC_ERROR(code) where code is the error code to be called. */
EC_ERROR(ERROR_ATTR_NOT_FOUND)
/* The EC_ERROR_If macro is similar to EC_ERROR but is conditional. Its format is
* EC_ERROR_IF(test, code) where test is a Boolean value and code is the
* error code to be called. */
lockVariable = MyAppCheckIfLocked(); /* TRUE if inaccessible. */
EC_ERROR_IF(lockVariable, ERROR_ACCESS_DENIED) /* Error if inaccessible. */
/* The EC_BOUNDS macro adds a call to ECCheckBounds() to the EC version.
* Its format is
* EC_BOUNDS(addr) where addr is the address to be checked. */
myPointer = MyAppGetMyPointer();
EC_BOUNDS(myPointer)
GEOS SDK TechDocs
|
|
5 The Error-Checking Version
|
5.2 Special EC Routines