macros and functions

Niels Möller
03 Mar 2003 21:47:15 +0100

Jason Moxham <> writes:

> A simple example of what I want is a fn like
> mpz_sizeinbase(mpz_srcptr Z , unsigned long BASE)
> most of the time we call this with BASE=2 , so ideally we want a macro which 
> can recognize this is a compile time constant and equal to two  and so 
> replace this with ABSIZ(Z)*GMP_NUMB_BITS+some_bits

You may be able to get some ideas from the section on "Other builtins"
in the gcc manual. In particular __builtin_choose_expr and

If you want the same name for the function and the "macro", that may
be easier to do using inline than with the preprocessor.