Created
August 28, 2018 12:42
-
-
Save johnmcfarlane/df4061be9d7c803204f99d72ca624101 to your computer and use it in GitHub Desktop.
code to test warning level of C++ translation unit
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
// code to test warning level of C++ translation unit; | |
// works with compilers which support `-Wpedantic` flag | |
// any warning level: 'extern' variable has an initializer [-Wextern-initializer] | |
// -Wall: "unused variable 'n' [-Wunused-variable]" | |
// -Wextra: "missing field 'b' initializer [-Wmissing-field-initializers]" | |
extern struct { int a, b; } n = {sizeof(void(*)(int))}; | |
// -Wpedantic: "variable length arrays are a C99 feature [-Wvla-extension]" | |
int evoke_pedantic_warning_vla(int n) { int a[n]; return a[3]; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment