Created
September 6, 2017 23:27
-
-
Save AbstractBeliefs/b428db0e09e5ff5e1721b1c9f01373ce to your computer and use it in GitHub Desktop.
This file contains 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
$ clang table.c -std=c99 -ggdb | |
table.c:17:17: warning: incompatible pointer types initializing 'int *(*)(int *)' with an expression of type 'int *(*[2])(int *)' [-Wincompatible-pointer-types] | |
for (int* (*manip)(int*) = manipulators; manip++; manip != NULL){ | |
^ ~~~~~~~~~~~~ | |
table.c:17:61: warning: inequality comparison result unused [-Wunused-comparison] | |
for (int* (*manip)(int*) = manipulators; manip++; manip != NULL){ | |
~~~~~~^~~~~~~ | |
table.c:17:61: note: use '|=' to turn this inequality comparison into an or-assignment | |
for (int* (*manip)(int*) = manipulators; manip++; manip != NULL){ | |
^~ | |
|= | |
2 warnings generated. |
This file contains 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> | |
#include <stdlib.h> | |
int* do_nothing(int* in){ | |
puts("Ok"); | |
return in; | |
} | |
int* (*manipulators[])(int*) = { | |
&do_nothing, | |
NULL | |
}; | |
int main(void) { | |
int someptr = 5; | |
for (int* (*manip)(int*) = manipulators; manip++; manip != NULL){ | |
manip(&someptr); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment