This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
__attribute__((unused)) is ignored in C++
- To: gcc at gcc dot gnu dot org
- Subject: __attribute__((unused)) is ignored in C++
- From: Matthias Klose <doko at cs dot tu-berlin dot de>
- Date: Fri, 5 Nov 1999 15:04:06 +0100 (MET)
- CC: 45440 at bugs dot debian dot org, Richard Kettlewell <rjk at sfere dot greenend dot org dot uk>
[This bug was reported to the Debian bug tracking system. Please CC
to 45440@bugs.debian.org.]
Tested with gcc-2.95.2
egcs ignores the __attribute__ syntax to mark a function parameter
unused, and then complains when it is not used. This only happens
when compiling C++, not C.
[The gcc manual does not talk about C++ variable attributes, only
C variable/function/type attributes. However the __attribute__
keyword seems to get recognized.
Embracing the function definitions with extern "C" results in the
same warnings.
Which attributes are expected to work in C++ and where should this
be documented?
]
$ cat foo.cc
int foo2(int __attribute__((__unused__)) x)
{
return 1;
}
int foo(int x __attribute__((__unused__)))
{
return 1;
}
$ g++ -Wall -c foo.cc
foo.cc:1: warning: `__unused__' attribute ignored
foo.cc:6: parse error before `__attribute__'