Great tool, but have just found an issue with macros and C/C++ code on Artistic Style v2.04 (on Windows if that makes any difference).
When using the "--add-brackets" (only option in the options file, no other options on command line), with code like:
#define SOMETHING(stmt) ; for (i = 0; i < 10; i++) SOMETHING(a+=5; a+=i;)
The reformatted code is:
for (i = 0; i < 10; i++) { SOMETHING(a+=5; } a+=i; )
Rather than:
for (i = 0; i < 10; i++) { SOMETHING(a+=5; a+=i;) }
When you have a single statement (with ";" inside the macro scope), the same issue occurs. (AStyle works fine in the more common case where there is only one statement terminator and it's outside the macro!)
Thanks and regards,
J
In fact, this issue doesn't have anything to do with the macro definition, you can reproduce this issue more simply like this:
Which is turned into:
(ie ")" outside of "}").
Here, the "if" is prompting the creation of "{ ... }", but the trailing ")" for the second macro ends up outside of that.