Created
April 9, 2021 02:10
-
-
Save klange/839d8904a5e7a1ac5f650e3eeb099356 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
#include <stdio.h> | |
struct Base { | |
int foo; | |
int bar; | |
}; | |
struct Sub { | |
struct Base; | |
int baz; | |
int qux; | |
}; | |
int main(int argc, char * argv[]) { | |
struct Sub sub; | |
sub.foo = 1; | |
sub.bar = 2; | |
sub.baz = 3; | |
sub.qux = 4; | |
return 0; | |
} |
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
$ gcc -o test test.c | |
test.c:9:13: warning: declaration does not declare anything | |
9 | struct Base; | |
| ^ | |
test.c: In function ‘main’: | |
test.c:17:5: error: ‘struct Sub’ has no member named ‘foo’ | |
17 | sub.foo = 1; | |
| ^ | |
test.c:18:6: error: ‘struct Sub’ has no member named ‘bar’; did you mean ‘baz’? | |
18 | sub.bar = 2; | |
| ^~~ | |
| baz | |
$ gcc -fms-extensions -o test test.c | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment