Skip to content

Instantly share code, notes, and snippets.

@AbstractBeliefs
Created September 6, 2017 23:27
Show Gist options
  • Save AbstractBeliefs/b428db0e09e5ff5e1721b1c9f01373ce to your computer and use it in GitHub Desktop.
Save AbstractBeliefs/b428db0e09e5ff5e1721b1c9f01373ce to your computer and use it in GitHub Desktop.
$ 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.
#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