On 12/20/2010 3:55 PM, Jeffrey Walton wrote:
> I'm interested in always using -Wall -Wextra as compile options, and I
> don't want others removing the options. So a make file is out of the
> question. I hope GCC will have something similar to an INI file (in
> /usr/share?), but search results have been heavily polluted with
> "function initialization" results.
>
> Some folks on the team are that lazy or l1t3 - they feel static
> analysis and warnings don't apply to their k3wl code.
Jeff,
I have never heard of such a config file for GCC, but you might be able
to re-build the compiler to specify default flags that it should use.
Or you might be able to get what you want by using environment variables
with make.
If you want to use additional flags when you build your project, you can
reference a variable from your Makefile (such as EXTRA_CFLAGS or
USER_CFLAGS). You can then populate that variable in your environment
login script (e.g. .bashrc, .cshrc, whatever).
Put the flags you want in there and no one else is forced to use them,
and no one can prevent you from using them. So, your Makefile might
look something like:
.c.o:
$(CC) $(CFLAGS) $(USER_CFLAGS) -c $<
When you run make, your environment's USER_CFLAGS (-Wall -Wextra) would
get inserted into the compiler command. When others run make,
USER_CFLAGS would simply be treated as an empty string.
If, on the other hand, you are trying to force other team members to use
certain flags when they compile their code, that may be more difficult.
But that's a project/team management issue that GCC probably can't
help you with.
-Tony