* __attribute__((unused)) is ignored in C++
@ 1999-11-05 6:13 Matthias Klose
1999-11-05 8:57 ` Joe Buck
1999-11-30 23:37 ` Matthias Klose
0 siblings, 2 replies; 4+ messages in thread
From: Matthias Klose @ 1999-11-05 6:13 UTC (permalink / raw)
To: gcc; +Cc: 45440, Richard Kettlewell
[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__'
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: __attribute__((unused)) is ignored in C++
1999-11-05 6:13 __attribute__((unused)) is ignored in C++ Matthias Klose
@ 1999-11-05 8:57 ` Joe Buck
1999-11-30 23:37 ` Joe Buck
1999-11-30 23:37 ` Matthias Klose
1 sibling, 1 reply; 4+ messages in thread
From: Joe Buck @ 1999-11-05 8:57 UTC (permalink / raw)
To: Matthias Klose; +Cc: gcc, 45440, rjk
> [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.
While this should be fixed, it tends to get low priority because there
is a standard, portable way in C++ to indicate that a variable is not
used:
int foo2(int)
{
return 1;
}
If you want to give the argument a name for documentation purposes,
the style I use is
int foo2(int /* x */)
{
return 1;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: __attribute__((unused)) is ignored in C++
1999-11-05 8:57 ` Joe Buck
@ 1999-11-30 23:37 ` Joe Buck
0 siblings, 0 replies; 4+ messages in thread
From: Joe Buck @ 1999-11-30 23:37 UTC (permalink / raw)
To: Matthias Klose; +Cc: gcc, 45440, rjk
> [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.
While this should be fixed, it tends to get low priority because there
is a standard, portable way in C++ to indicate that a variable is not
used:
int foo2(int)
{
return 1;
}
If you want to give the argument a name for documentation purposes,
the style I use is
int foo2(int /* x */)
{
return 1;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* __attribute__((unused)) is ignored in C++
1999-11-05 6:13 __attribute__((unused)) is ignored in C++ Matthias Klose
1999-11-05 8:57 ` Joe Buck
@ 1999-11-30 23:37 ` Matthias Klose
1 sibling, 0 replies; 4+ messages in thread
From: Matthias Klose @ 1999-11-30 23:37 UTC (permalink / raw)
To: gcc; +Cc: 45440, Richard Kettlewell
[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__'
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1999-11-30 23:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-05 6:13 __attribute__((unused)) is ignored in C++ Matthias Klose
1999-11-05 8:57 ` Joe Buck
1999-11-30 23:37 ` Joe Buck
1999-11-30 23:37 ` Matthias Klose
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).