How can I write the next logical expression in Inno Setup properly?

Viewed 86

Here's the pseudocode for what I need to write using the preprocessor directives:

(IF VAR == NOT DEFINED) OR (VAR == DEFINED AND VAR == 0) THEN
{a few lines of code}

How can I write that logical expression in one line?

I tried this:

#if (defined(VAR) == 0) || ((defined(VAR) == 1) && (VAR == "0"))

but it didn't work. It says:

Undeclared identifier: "VAR".

1 Answers

Your code seems reasonable. I would have expected it to work too.

Anyway, your code gives an impression that "0" should be a default value of the VAR. So this should do:

#ifndef VAR
#define VAR "0"
#endif

#if VAR == "0"
{a few lines of code}
#endif
Related