Skip to content

Instantly share code, notes, and snippets.

@rossy
Created June 17, 2012 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rossy/2943702 to your computer and use it in GitHub Desktop.
Save rossy/2943702 to your computer and use it in GitHub Desktop.
GCC Lexical Closures
#include <stdio.h>
void sayHello(void (*log)(char*))
{
log("Hello, world!");
}
int main(int argc, char** argv)
{
void log(char* message)
{
printf("%s: %s\n", argv[0], message);
}
sayHello(log);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment