sizeof(function) functionality

Alexandre Oliva aoliva@redhat.com
Tue Jul 8 22:21:00 GMT 2003


On Jul  8, 2003, Ben Davis <bndavis@ntlworld.com> wrote:

> Oops, I forgot to give an example of usage (not that you probably need it :)
> On Tuesday 8 July 2003 1:56 pm, Ben Davis wrote:
>> #define DEFINE_SIZED_FUNCTION(rtype, name, params, body) \
>> rtype name params body \
>> void endof_##name(void) { }
>> 
>> #define DECLARE_SIZED_FUNCTION(rtype, name, params) \
>> rtype name params; \
>> void endof_##name(void);

> DECLARE_SIZED_FUNCTION(float, myfunc, (float x, float y))

> DEFINE_SIZED_FUNCTION(float, myfunc, (float x, float y), {
>     return (float)sqrt(x*x + y*y);
> })

Beware!

DEFINE_SIZED_FUNCTION(float, myfunc, (float x, float y), {
  float x2 = x*x, y2 = y*y;
             // ^ oops, this is not a macro argument separator
  return (float)sqrt(x2+y2);
}

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer



More information about the Gcc-help mailing list