Macros return values

This is a discussion on Macros return values within the C Programming forums, part of the General Programming Boards category; How does one code a macro to return a value?
I need to create two macros max1(x,y) max2(x,y,z)
Need to ...

It's still not how such a macro is meant to be written.
You should be able to use it like MAX2(5, 7) or with variables of other names.
For this you need parameters to the macro.
A quick search and you will find the answer.

There are several reasons to use macros, the major one is to create a function template which can be applied to different types of arguments, typically the whole range of integers and floats.
This is the case for your MAX macros.
I suggest you first write the C function (without macro) to compute the max of two ints

Code:

int max(int x, int y) { ... }

Once it's done, remove the types and adjust the syntax to make it a macro.

What iMalc was saying is that x and y are just formal parameters.
With the macros MAX, i expect to be able to do:

Ah. The gist of this has already been stated in posts #3, #5 and #6. If I were to add my own explanation...

Think back on the advantage of a function: you can call it with different arguments, execute the same operation, and obtain a result. Same function, different input, it works.

The same applies for a function-style macro: you supply the macro with different arguments, and then you get the same macro replacement (the "return" of a value). If you did not use a function-style macro, then you cannot supply arguments. It is as if you are using global variables, and you're stuck with particular names.

With your MAX2 macro, we cannot do this: there is no way to get the max of y and z without writing more code that does the same operation of finding the max of two values... at least not without changing the values of x and y.