You don't explain what you really want and why you are (incorrectly) using a macro. I'm guessing that it is because you think that macros run faster.
Then just define an inline
function like
static inline int ProdottoAumentato(int x, int y)
{ return (x+1)*y; }
with most optimizing compilers (e.g. gcc -Wall -O2
if using GCC....), this is as fast as your attempted macro, because the compiler will do inline expansion.
If for some strange reason you still want to use macro and the C preprocessor, check its output, e.g. by running gcc -C -E yourcode.c > yourcode.i
then look (with a pager like less
or some source code editor) into the generated yourcode.i
containing the preprocessed form.
As a rule of thumb, you generally need to add extra parenthesis in macro definitions:
#define ProdottoAumentato(X,Y) ((X)+1)*(Y))
otherwise ProdottaAumentato(u+3,v+5)
won't be expanded like you wish, since the preprocessing is a purely textual operation.
You might also use statement exprs (a useful GCC extension) and have
#define ProdottoAumentato(X,Y) ({int _x = (X); int _y = (Y); (++_x * _y)})
You might define two global variables; int xx, yy;
and have
#define ProdottoAumentato(X,Y) ((xx=(X),((yy=(Y)),((++xx)*yy))
using the comma operator.