Question: When you see a line like:

```
#define IX(i,j) ((i)+(N+2)*(j))

```

is that equivalent to:

```
int IX(int i, int j) {

    return ((i)+(N+2)*(j));

}

```

How do you know the return type etc?

Answer: 
Macros never get seen by the compiler - the preprocessor replaces the text.

So, when you write:

```
result = IX(5, 3);
```

The compiler will see this:

```
result = ((5)+(N+2)*(3));
```

This can have impacts on behaviour, but it depends on your macro. In this case, not so much (there are also performance and debugging differences, but let's not worry about them here).

Had, for example, you defined your macro like this (note second use of *i* variable)

```
#define IX(i,j) ((i)+(i+2)*(j))
```

And called it like so:

```
result = IX(++i, j);
```

Then the macro and function would have different behaviour.
Yes and no: they don't work the same way, but *in this particular case*, the effect will be the same if you only use arguments of the type you'd use in the function signature.

Macros are really just text substitution performed before actually compiling the code, so no type information is needed; the macro use is simply replaced with the macro content, and the rest is left to the compiler.

What that means is that `IX(i++,j--)` is executed differently depending on whether it's a function or a macro: if it's a macro, the arguments are evaluated when referred to, if it's a function, they're evaluated when the function is called.

Since no parameter is referred to twice, there is no observable difference after each of those has been executed, but they're still treated differently.

As a rule of thumb, if what you're trying to do requires code to be placed at a specific place, then you can use a macro; otherwise you should use a function.