I want to write in Makefile like this
foo: foo.c
$(CC) -o foo -Wall foo.c
but I'm not sure if all cc
implementations support -Wall
.
I want to write in Makefile like this
foo: foo.c
$(CC) -o foo -Wall foo.c
but I'm not sure if all cc
implementations support -Wall
.
No, there is no standard regarding the command-line interface of C compilers.
The Microsoft compiler (in Windows) for instance does not accept options starting with -
at all, since that's not the syntax typically used with Windows programs.
No, the closest thing you can do to use only portable options is to restrict yourself to the POSIX C89 and C99 options. -Wall
is not one of them. See the Opengroup's Unix Specification for c99 for options which are. And that only gives answers for unixy systems, not Microsoft.
-Wall
was (AFAIK) introduced by GNU gcc
and inherited by clang
to be compatible with GNU gcc
.
If you are not afraid to research other build tools, there are some that support multi-OS or multi-toolchain builds out of the box. I believe scons
and cmake
can do this.