mario razzu
mario razzu

Reputation: 383

Wrong macros definition casuses "Expected expression" error

I have these macros:

#define TRUE 1;
#define FALSE 0;

I want to use them in an if condition, for example:

if (functionThatReturnsIntZeroOrOne() == FALSE) do_something();

but I get such an error message:

"Expected expression". 

What do I do wrong?

Upvotes: 4

Views: 7826

Answers (1)

iobender
iobender

Reputation: 3486

You defined FALSE to be 0;, define it to be 0 (#define FALSE 0, without a semicolon). The semicolon is included in the define, so FALSE gets replaced with 0; which puts a semicolon in your if conditional.

Upvotes: 10

Related Questions