Mikroelektronika MIKROE-738 Datenbogen

Seite von 682
mikroC PRO for PIC32
MikroElektronika
189
Parentheses
Parentheses 
(  )
  are  used  to  group  expressions,  isolate  conditional  expressions,  and  indicate  function  calls  and 
function parameters:
d = c * (a + b);     /* override normal precedence */
if (d == z) ++x;     /* essential with conditional statement */
func();              /* function call, no args */
void func2(int n);   /* function declaration with parameters */
Parentheses are recommended in macro definitions to avoid potential precedence problems during an expansion:
#define CUBE(x) ((x) * (x) * (x))
For more information, refer to Operators Precedence And Associativity and Expressions.
Braces
Braces 
{ }
 indicate the start and end of a compound statement:
if (d == z) {
  ++x;
  func();
}
Closing brace serves as a terminator for the compound statement, so a semicolon is not required after 
}
, except in 
structure declarations. Sometimes, the semicolon can be illegal, as in
if (statement)
   { ... };    /* illegal semicolon! */
else
   { ... };
For more information, refer to the Compound Statements.
Comma
Comma (
,
) separates the elements of a function argument list:
void func(int n, float f, char ch);
Comma is also used as an operator in comma expressions. Mixing two uses of comma is legal, but you must use 
parentheses to distinguish them. Note that (exp1, exp2) evalutates both but is equal to the second:
func(i, j);                              /* call func with two args */
func((exp1, exp2), (exp3, exp4, exp5));  /* also calls func with two args! */