Skip to content

Instantly share code, notes, and snippets.

@westfly
Created September 29, 2019 05:49
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 westfly/a9c0a80c609951acb99cbd5a0895e1dc to your computer and use it in GitHub Desktop.
Save westfly/a9c0a80c609951acb99cbd5a0895e1dc to your computer and use it in GitHub Desktop.
debug宏定义的参数为lambda
#ifdef DEBUG
#define macro(labmda) \
do { \
labmda; \
} while (0)
#define macro_call(labmda) \
macro(labmda())
#else
#define macro(labmda)
#define macro_call(labmda)
#endif
#include <stdio.h>
int main(int argc, char *argv[]) {
int x = 100;
macro([&]() {
printf("hello %d\n", x); }()
);
macro([](int x) { printf("hello %d\n", x); }(x));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment