`clang -ansi` extensions
c, c89, clang, gcc
Solution
If you are trying to disable extensions in `-ansi` mode, then you want these warnings treated as errors: use `-pedantic-errors` instead of `-pedantic`, or `-Werror` (or both). For more fine-grained control over errors, see the Clang manual.
Problem
I ran into an issue recently where the following toy example compiles cleanly using `clang -ansi`: ``` int main(void) { for (int i = 0; 0; ); return i; } ``` but `gcc -ansi` gives the following error: ``` a.c: In function ‘main’: a.c:3:5: error: ‘for’ loop initial declarations are only allowed in C99 mode a.c:3:5: note: use option -std=c99 or -std=gnu99 to compile your code ``` Compiling with `clang -ansi -pedantic` shows that a C99 extension is being used. ``` a.c:3:10: warning: variable declaration in for loop is a C99-specific feature [-pedantic,-Wc99-extensions] for (int i = 0; 0; ); ^ 1 warning generated. ``` What other extensions does clang allow with the `-ansi` option? How can I disable them?