NESHLA: Reference: Preprocessor Keywords:

NESHLA includes preprocessor keywords for defining labels which can store code and data, or control compilation flow.

 Definition Declarations

 #define label[, value]

The #define directive gives the ability to eliminate code duplication and enhance code readability. By defining magic numbers with names, code readability can be enhanced, and adjustments can be made easily.

Defines can be used with the conditional preprocessor define directives as well to control the compiler's compilation. See Conditional Defines.


// defining boolean true/false integers
#define TRUE  1
#define FALSE 0

// defining an integer for the size of a name table
#define NAME_TABLE_SIZE 0x03C0

// defining a string
#define PROGRAM_VERSION "Version 1.0"

// defining a binary bitmask
#define ST_VBLANK %10000000

// defining a condition control

 #undef label

The #undef directive allows the deletion of previously defined labels. It is useful when limiting a define to a certain scope. As well, it can be useful for use with Conditional Defines.


// undefining a previously defined integers
#undef TRUE
#undef FALSE

// undefining a previously defined string

// undefining a previously defined binary bitmask
#undef ST_VBLANK

// undefining a previously defined condition control

 Conditional Defines

 #ifdef, #ifndef, #else, #endif

The #ifdef and #ifndef directives give the ability to control the flow of compilation. They can be used to make the compiler skip certain code and data, or only pass through certain code and data once. The #else directive allows you to have a fall through condition block for when the condition evaluates to false. Finally, each conditional define is terminated with an #endif directive.


/* if a #define DEBUG_MODE has been previously declared, then the PROGRAM_VERSION will be defined with the debug string. Otherwise, if it was not, or was undefined with the #undef directive, the PROGRAM_VERSION will be defined with the release string */
PROGRAM_VERSION "Version 1.0 (Debug)"
PROGRAM_VERSION "Version 1.0 (Release)"

/* To allows headers to be included in multiple files without being repeatedly parsed, the conditional define keywords can be used as well */
// insert header file contents here


<< Back To Index