Created
March 30, 2019 01:33
-
-
Save alphaKAI/abcf88aa5622eaf219bb9ba5f9cd19a5 to your computer and use it in GitHub Desktop.
FAKE nested function defintion def in C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define INNNER_FUNC_PROT(N, RET, func_prot) \ | |
func_prot; \ | |
RET inner_func_ ##N ## _next(); | |
#define INNNER_FUNC_DEF(N, RET, func_name, func_def) \ | |
func_name (); \ | |
return inner_func_ ## N ## _next(); \ | |
} \ | |
func_def \ | |
RET inner_func_ ## N ## _next() { \ | |
INNNER_FUNC_PROT(1, int, void func()); | |
int f() { | |
INNNER_FUNC_DEF(1, int, func, | |
void func() { | |
int x = 2 * 3; | |
printf("inner func! x : %d\n", x); | |
}); | |
return 0; | |
} | |
int main(int argc, const char *argv[]) { | |
f(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment