cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
vsrini
Level 3

Preprocessor Directives

I am observing that #else condition is firing even if #if is satisfied.

Project Type: InstallScript project

Snippet of my code in Setup.Rul:



#define FOO 1
#if (FOO = 1)
MessageBox("FOO = 1",INFORMATION);
#elif (FOO = 2)
MessageBox("FOO = 2",INFORMATION);
#elif (FOO = 3)
MessageBox("FOO = 3",INFORMATION);
#else
MessageBox("FOO = something else",INFORMATION);
#endif


Two message boxes pop-up with messages "FOO = 1" and "FOO = something else".

Has anyone observed this behavior?

Thanks
Labels (1)
0 Kudos
(1) Reply
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

This is a known issue with the InstallScript compiler's preprocessing support that was previously reported in work order IOA-000012862.

You can work around this behavior by replacing any '#else' statements in a preprocessor block that contains any #elif statements with:
#elif 1

This should also work anywhere #else is used, but is really only necessary as a workaround in preprocessor blocks like the one in your post.

This issue occurs due to how the compiler handles the #else after an #if or #elif was true, and a subsequent #elif was found. Replacing #else with #elif 1 avoids this behavior.
0 Kudos