Difference in behavior with clang and gcc using the same flags?

Viewed 346

On my dev machine, building my project with the following command produces no error.

clang -Wall -std=c89 main.c

However, on another machine which has gcc, using the following command produces an error.

gcc -Wall -std=c89 main.c

main.c:65: error: 'for' loop initial declaration used outside C99 mode

Why is there this difference in behavior?

Here are the versions of clang and gcc I'm using.

clang --version
Apple LLVM version 9.0.0 (clang-900.0.37)

gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-54)
1 Answers

Clearly clang is being permissive, accepting c99 code under c89 flag.

Related