0

I am building my own game engine .... and I came across this error:

error: expected identifier or '('

here's the code:

#define RX_ASSERT(expr )
    { 
        if {(expr)}{

        }
        else
        {
            report_assertion_failure(#expr, "", __FILE__, __LINE__);
            debugBreak();
        }
    }

#define RX_ASSERT_MSG(expr, message )
    { 
        if {expr}{

        }
        else
        {
            report_assertion_failure(#expr, message, __FILE__, __LINE__);
            debugBreak();
        }
    }

I tried to compile this in Clang, but it failed :(

Alexander
  • 59,041
  • 12
  • 98
  • 151
Hari K
  • 1
  • 1
    `if {expr}` is invalid syntax. – Alexander Nov 25 '22 at 17:28
  • 1
    If those are meant to be two macros, then you need to end all lines except the last with a backslash. Otherwise, if that appears outside a function, it is syntactically invalid. And the `if {expr}` comment from @Alexander is completely valid, whether this is meant to be two macros or not. You might be meaning `if (!(expr))` which eliminates the need for an empty statement after the `if` — you'd place your current `else` clause as the body of the `if`. See also [Why use apparently meaningless `do`/`while` and `if`/`else` statements in macros?](https://stackoverflow.com/q/154136/15168) – Jonathan Leffler Nov 25 '22 at 17:39

0 Answers0