This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: __attribute__ vs c++
- To: nbecker at fred dot net
- Subject: Re: __attribute__ vs c++
- From: Bill Currie <bcurrie at tssc dot co dot nz>
- Date: Fri, 16 Oct 1998 10:00:28 +1300
- CC: egcs-bugs at cygnus dot com
- Organization: NZ Telecommincations Systems Support Center
- References: <E0zTplM-0006wy-00@hns.com>
nbecker@fred.net wrote:
>
> egcs-1.1a i686-pc-linux-gnu.
>
> bug.cc:
> class A {
> const int x;
> int X () const __attribute__((const)) {
> return x;
> }
> };
>
> gcc -c bug.cc
> bug.cc:3: parse error before `{'
>
> Is __attribute__ not usable for methods?
Try treating the __attribute__ as a type modifier. ie:
...
int __attribute__((const)) X () const {
return x;
}
...
This is how you do this in C. __attribute__ can be used with methods in
C++; I have (gcc 2.7.2.1) but the definition of the method was separate
from the class definition (inlining was inappropriate).
Bill
--
Leave others their otherness