#include <stdio.h>
int i;
//pass by name
#define THREE_TIMES( a ) \
({ \
int total = 0; \
total += a; \
++i; \
total += a; \
++i; \
total += a; \
total; \
})
//same function, pass by value
int three_times( int a )
{
int total = 0;
total += a;
++i;
total += a;
++i;
total += a;
return total;
}
//called both ways
int main( )
{
int array[] = {1,2,3};
i = 0;
printf( "pass by name: %d\n" , THREE_TIMES(array[i]) );
i = 0;
printf( "pass by value: %d\n" , three_times(array[i]) );
return 0;
}