-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error with functions returning functions #99
Comments
You could do it with external struct defines as static in c: #include <stdio.h>
struct Template { int a1; int a2; };
static struct Template temp;
int nestedfunc(void) {
return temp.a1 + temp.a2;
}
int* (* func1(int arg1, int arg2))(void) {
temp.a1 = arg1; temp.a2 = arg2;
return (int* (*) (void)) nestedfunc;
}
int main() {
temp.a1 = 0; temp.a2 = 0;
printf("%d\n", func1(1, 2)());
return 0;
} However, it's unable in ISO C/C++ to directly nest functions- it's GCC/G++ feature. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: