Conditional Compilation

An annotated screenshot of TIDE's File Conditiion dialog.

Apart from the standard preprocessor directives, TIDE allows you to conditionally include or exclude entire files on the project tree level. To achieve this, right-click on a file in the project tree and select Condition. The File Condition dialog will appear.

Leaving the condition string empty means that a file is always included into the compilation. Setting an expression means that a file will be included only if the expression evaluates to TRUE.


File-level inclusion/exclusion is performed before the compilation of any files. Therefore, macro names (often incorrectly referred to as "preprocessor variables") are not visible at this state.


Names that can be used are displayed by the File Condition dialog.

Their origin can be examined in the Customize Project dialog (File > Project Settings > Customize):


The expression assumes that this is an #if—#endif construct, so you don't actually have to type in #if and #endif, just the expression "in between."

Standard BASIC preprocessor syntax is used in the expression strings, even when you are setting conditions for a C file.

This is correct: OBJECT_LCD=LCD_ENABLED AND OBJECT_FD=FD_DISABLED

This is incorrect: OBJECT_LCD=LCD_ENABLED && OBJECT_FD=FD_DISABLED

In other words, use "AND", "OR", or "<>" (not "&&", "||", or "!=").


Conditions cannot be set for header files (.TBH and .TH). The header files are in the project tree for your editing convenience, nothing else. The inclusion of these files into the compilation is handled by the include statement. Use preprocessor directives to include a header file conditionally. For example:


TIBBO BASIC
#if PLATFORM_ID=DS1101W
   include "global.tbh"
#endif