This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

__attribute__((unused)) is ignored in C++


[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__'


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]