Conditional Compilation

Top  Previous  Next

file condition_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 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 Condition dialog.

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

Platform definitions are from the platform itself and can't be changed by you.
Custom definitions are yours to edit.

 

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", "<>" and not "&&", "||", "!=".

 

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