I have a macro which detects a prefix at the beginning of a symbol. These prefixes indicate a 16 bit value, arranged as structures of arrays, to direct how the macro generates code. I simply want to detect one prefix OR the other prefix. When I try to put the two below invocations of a c-style macro in an || expression, ca65 errors out. Even if I use parentheses around each macro invocation and around the entire expression itself. I was able to work around this using .set as in the below code snippet, but is ca65's expression parsing really this broken?

Code:

entity_prefix .set starts_with .string(arg), "entity_" lut_prefix .set starts_with .string(arg), "lut_" .if entity_prefix || lut_prefix ;I can't just put the two macros on either side of the || or I get errors, even with parentheses applied liberally. I had to use this workaround.

I believe that the reason you can't use the macros directly in the IF statement is because ca65 doesn't know when the last parameter of a c-style macro ends. In that case, delimiting the last parameter with {} should work. Something like this:

I believe that the reason you can't use the macros directly in the IF statement is because ca65 doesn't know when the last parameter of a c-style macro ends. In that case, delimiting the last parameter with {} should work. Something like this:

Sorry my OP was not terribly clear---doing this works for me, my question was why can't I just put the macro invocation directly surrounding the ||. Using the { } in each invocation as you suggested allows me to do so, so I've removed the two prefix variables. I now have:

Who is online

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum