macros and functions

delta trinity deltatrinity@hotmail.com
Mon, 03 Mar 2003 10:12:08 -0500


I think you either have a choice of having a function OR having a macro 
(unless I am mistaken).  A macro is not a function in itself.  It rather 
insert itself at every places where you invoke it in your code.  So when 
declaring a macro, no code is actually created (so you can't take a macro's 
address).  When using a macro, code is generated at every places where you 
invoke it.

Well, one way of doing what you may want is to wrap the macro in a function, 
like this:

#define Macro1(Param1, Param2) \
{                              \
   //Do some stuff             \
}

void Func_Macro1(mpz_t Param1, mpz_t Param2)
{
   Macro1(Param1, Param2)
}

So, in your code, you can call Func_Macro1 or simply use the Macro1 macro.

Eric

>I'm experimenting with adding some new functions to gmp and ideally I would
>like some of them to be macros , but also availible as functions if 
>required
>(say if address is taken). What existing function (mpn if possible) has 
>this
>property , a nice simple one please. Also I would like this to be availible
>to the library itself (internal) and external (users of the lib) , 
>hopefully
>under the same name
>
>thanks
>
>Jason


_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online  
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963