This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/46115] Feature request: anonymous functions (complementing anon aggregates)


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46115

--- Comment #3 from Rob Staudinger <robert.staudinger at gmail dot com> 2010-10-25 07:31:59 UTC ---
For the record, this is already possible using bracketed expressions, but the
syntactical sugar of not having to pick a function name would be great.

#include <stdio.h>
#include <stdlib.h>

int
main (int argc, char **argv)
{
  void (*func_ptr)(int) = ({ void func(int i) { printf ("%i\n", i); };
                             func;
                           });

  func_ptr (3);

  return EXIT_SUCCESS;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]