#ifdef and #ifndef

InstallShield 2020 » InstallScript Language Reference

Use the #ifdef statement when you want to compile a section only if a specified expression has been defined with #define. Use #ifndef when you want to compile a section only if a specified expression has not been defined.

Example

#ifdef A

    // Compile if A is defined.

    . . .

#endif

 

#ifndef A

    // Skip if A is defined; otherwise compile.

    . . .

#endif

 

#ifdef A    // Compile if A is defined.    . . .#endif#ifndef A    // Skip if A is defined; otherwise compile.    . . .#endif

You can also use #ifdef and #ifndef with #else and #elif:

#ifdef nFilePath

    //statements

#else

    //statements

#endif

Note:Preprocessor defines can be entered in the Project Settings dialog box's Compile/Link tab's Preprocessor Defines edit box. If you add or change a preprocessor definition in the Project Settings dialog box, you must recompile your setup for the changes to take effect.

Restrictions

Keep in mind the following restrictions when using #ifdef and #ifndef statements:

You cannot place comments on the same line as #ifdef and #ifndef directives.
Do not test a constant that has a value of 0 (zero) with an #ifdef or #ifndef statement.
You can test only numeric constants with an #ifdef or #ifndef statement.