[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug or not? Order of compiler warning flags matters
From: |
Marcel Loose |
Subject: |
Bug or not? Order of compiler warning flags matters |
Date: |
Mon, 22 Nov 2004 13:44:58 +0100 |
Hi all,
I'm not sure whether this is a bug, or "expected" GCC behaviour. Hence, I
want to check here first, before submitting a bug report.
Consider the following code:
void f(int i)
{
}
int main()
{
f(1);
return 0;
}
Compiling this with -Wall -W correctly produces the warning about the unused
parameter `int i'.
Adding the flag -Wno-unused-parameter suppresses this warning, but ONLY when
it is added AFTER the -Wall switch.
$ gcc -W -Wall -Wno-unused-parameter t.cc
OK, silent.
$ gcc -W -Wno-unused-parameter -Wall t.cc
t.cc: In function `void f(int)':
t.cc:2: warning: unused parameter `int i'
Not OK. I don't want this warning.
Now it wouldn't be such a big deal if I would have complete control over the
order of the compiler flags. However, since we use the GNU Autotools for our
project, I decided to use "AM_CXXFLAGS = -Wno-unused-parameter" in my
Makefile.am. As you might guess, automake (or one of the other auto-tools)
places this flag as the very first, after some flags (like -Wall -W) that
are added by default to our list of compiler flags. Hence, the flag is
effectively ignored.
Could anyone shed a light on this issue. Thanks in advance.
Kind regards,
Marcel Loose.
- Bug or not? Order of compiler warning flags matters,
Marcel Loose <=