We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi experts,
i am trying to define a macro in the format
#define SUM(x,y) ({log_var = x; log_var += y;})
void main(void)
{
unsigned int log_var;
SUM(10,20);
}
Compilation of the same by ARMCC throws an error "Expected an expression" but compilation with GCC doesn't throw the error.
Is it the syntax "({<statements>});" is not allowed in ARMCC or is there any other reason for the same ?
The same disappears when the parentheses is removed. i.e "{<statements>}"
Message was edited by: techguyz
The ({ ... }) syntax is not part of standard C or C++; it is a GNU extension called a "statement expression". But armcc allows you to turn on GNU extensions: http://infocenter.arm.com/help/topic/com.arm.doc.dui0472j/chr1359124965274.html