In the first version your declaration of y comes within a block of
dead code! All execution paths before that return from main, so everything below the if statement will never be executed.
Solution: Don't use premature return statements. It is a bad practice anyhow. Instead use a variable to hold the return value, and execute the remainder of the code dependend on that value, e. g. like this:
int main() {
BOOL x;
int result = 0;
if (x)
result = 1;
else
result = 2;
if (result == 0) {
BOOL y;
y = FALSE;
}
return result;
}
Note that while the declaration of y is still
semantically dead code (i. e. the semantics of your code prevent it from being executed), the compiler will no longer complain, because
syntactically the code is still 'alive'.
P.S.: I just wondered why this would produce an error - it should at worst produce a warning. The error you got is quite probably caused by something different. After looking at your posting again, I noticed that you mentioned having included windows.h only in the second version - and as others have pointed out you'd need that for the definition of the symbols of BOOL and FALSE.
Sorry for bothering you with a solution to a problem you hadn't asked about ;)