I've the following code which is using preprocessor conditional compilation directives:
#define foo
#define bar
#ifdef foo || !bar
extern bool Verbose = FALSE;
#else
extern bool Verbose = TRUE;
#endif
void start() {
}
which doesn't compile, because of the following error:
test.mq4(3,12) : error 175: '
||
' - expressions are not allowed on a global scope
However the code compiles fine when the first line (foo) is commented out which seems the compiler allows this expression in a global scope in that case (when foo is not defined).
You can try compiling above code using mql
compilator (under Linux use wine
):
mql.exe /mql4 test.mq4
So the question is:
Why this doesn't work
and
how do I define above preprocessor condition (foo || !bar
)
in a proper way?
I've also tried the following syntax:
#if defined (foo) || defined (!bar)
as suggested previously by user2357112 (GNU cpp syntax), but it fails with the following errors:
error 109: '
#if
' - invalid preprocessor commanderror 149: '
#else
' - unexpected token
it's because the MQL syntax is completely different and it doesn't support these kind preprocessor commands.