Re: sizeof(function) functionality

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jul  8, 2003, Ben Davis <bndavis@xxxxxxxxxxxx> 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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux