macros and functions
Jason Moxham
J.L.Moxham@maths.soton.ac.uk
Wed, 5 Mar 2003 19:52:12 +0000
On Monday 03 Mar 2003 10:18 pm, Kevin Ryde wrote:
> Jason Moxham <J.L.Moxham@maths.soton.ac.uk> writes:
> > What existing function (mpn if possible) has this property , a nice
> > simple one please.
>
> In glibc stdio.h you can see putc given first as a prototype then a
> #define. When used as a function pointer it hits the prototype.
>
> I don't know if it's a normal feature for cpp to ignore the define
> when it's used without a parameter list. It could well be normal, but
> glibc is highly dependent on gcc so it may not have been exercised
> widely.
>
> We can't do this in gmp however, because it would mean the function
> would be plain mpz_foo, whereas we want it to come out as __gmpz_foo.
> I think I tried an extra level of macroing one time, without success.
>
If you can't do it , then I'm not going attemp it :)
> nisse@lysator.liu.se (Niels M=F6ller) writes:
> > If you want the same name for the function and the "macro", that may
> > be easier to do using inline than with the preprocessor.
>
> That probably comes out cleanest. The only thing to consider is that
> not all compilers have an inline, and not all are recognised by the
> inline business in gmp.h, so one could end up with applications
> written in a style that only certain compilers can do a good job with.
> Better to try to ensure everyone is equal.
I think I'll just use
function mpn_function(x,y)
macro MPN_FUNCTION(x,y)
and have to remember to call the correct one
thanks
Jason