Unnamed functions, functors or, more formally, function literals

Lars Brinkhoff lars.spam@nocrew.org
Fri Mar 15 23:10:00 GMT 2002


This macro will return (something that is at least close to) an
anonymous function:

#define ANON(type, args, body) ({ type __anon__ args body; &__anon__; })

Example:

  printf ("%d\n", ANON (int, (int x), { return x + 2; }) (x));

-- 
Lars Brinkhoff          http://lars.nocrew.org/     Linux, GCC, PDP-10,
Brinkhoff Consulting    http://www.brinkhoff.se/    HTTP programming



More information about the Gcc mailing list