0

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?

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Zolookas
0

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...

Edited by mike_2000_17: Fixed formatting

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.