I have a very simple one line function and i want to replace it with macro, but macro doesn't seem to work.

Function:

int stack_empty(stack ** this_stack) 
{
	return *this_stack == NULL;
}

Macro i am trying to use:

#define stack_empty(x) (*x == NULL)

Anybody knows what i am doing wrong?

Better post a code where macro doesn't seem to work.
More accurate this substitution definition is

#define stack_empty(x) (*(x) == 0)

However it's a strange parameter type stack**. It has two indirections - why?

If you have a modern (standard-compliant) compiler better use inline keyword...

Thanks, i thought inline was c++ feature.

I use two indirections, because my other functions require them and I want to keep it simple to use.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.