Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // by @MikailBag
- // the simple code compiles without any warnings under -Wall BUT
- // ❯❯❯ ./test
- // [1] 12892 segmentation fault (core dumped) ./test
- // However with Wextra it warns:
- // ❯❯❯ gcc -Wextra -o test test.c
- // test.c:16:1: warning: missing initializer for field ‘f3’ of ‘struct Foo’ [-Wmissing-field-initializers]
- // };
- // ^
- // test.c:7:12: note: ‘f3’ declared here
- // void (*f3)(void);
- // ^~
- #include <stdio.h>
- struct Foo {
- void (*f1)(void);
- void (*f2)(void);
- void (*f3)(void);
- };
- void g1(void) { printf("g1"); }
- void g2(void) { printf("g2"); }
- static struct Foo foo = {
- g1,
- g2
- };
- int main() {
- foo.f1();
- foo.f2();
- foo.f3();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement