[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] GCC question
Peter Slegg wrote:
#define TREE_XYWH(tree) tree[0].ob_x-3,tree[0].ob_y-3,tree[0].ob_width+6,tree[0].ob_height+6
objc_draw(dlog, start, MAX_DEPTH, TREE_XYWH(dlog));
newsaes.c:651:52: error: macro "objc_draw" requires 7 arguments, but only 4 given
Let's restart to the beginning.
First, what is objc_draw() ?
/opt/cross-mint/m68k-atari-mint/include/gem.h:
#define objc_draw(a,b,c,d,e,f,g) mt_objc_draw(a,b,c,d,e,f,g,aes_global)
So with the GemLib (used by GCC), objc_draw() is a macro taking 7 arguments.
If you try to call it with any other number of arguments, it the compilation
will quickly fail at preprocessing stage.
This is what is happening to you, and why you are getting the error.
With Pure C, which use a different GemLib, objc_draw() is probably defined
as a real function. So the expansion of the macro TREE_XYWH() occurs before
the call to the function objc_draw(), and it works.
So what is the solution with GCC and the GemLib ?
Create a new macro with 4 arguments:
#define objc_draw4(a,b,c,d) objc_draw(a,b,c,d)
Then whenever there is a call to objc_draw() with 4 arguments, use
objc_draw4() instead:
objc_draw4(dlog, start, MAX_DEPTH, TREE_XYWH(dlog));
And this will work.
Finally, this is not a GCC or Pure C issue. This is a GemLib issue. Since
the GemLib functions are implemented as macros, they don't allow to be
called with macro arguments which expands to several arguments like TREE_XYWH().
Anyway, that kind of macro should be considered as evil.
--
Vincent Rivière