* __attribute__((deprecated)) and inline constructors
@ 2003-01-08 10:25 Vaclav Slavik
0 siblings, 0 replies; only message in thread
From: Vaclav Slavik @ 2003-01-08 10:25 UTC (permalink / raw)
To: gcc-help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I'm having some problems with gcc 3.2 and __attribute__((deprecated))
when used in combination with inline functions. I need to add the
attribute to quite a few methods in several classes. These deprecated
methods are implemented inline, as in this example:
class X {
public:
X() {}
void foo() {}
};
But this doesn't compile ("parse error before `{' token"):
class X {
public:
X() __attribute__((deprecated)) {}
void foo() __attribute__((deprecated)) {}
};
I found that this works:
class X {
public:
__attribute__((deprecated)) void foo() {}
};
but I didn't find such use of __attribute__ in gcc documentation, so
I'm not sure it will continue to work in future gcc versions. More
importantly, it doesn't work with constructors, this doesn't compile:
class X {
public:
__attribute__((deprecated)) X() {}
};
The only working solution I found so far is to move the implementation
outside of class { ... } statement:
class X {
public:
X() __attribute__((deprecated));
void foo() __attribute__((deprecated));
};
inline X::X() {}
inline void X::foo() {}
But I'd like to avoid it if possible both because of the amount of
deprecated methods and because inline implementation at the line
pointed to by gcc warning serves as a hint how to fix code that uses
deprecated calls.
Is there some way to do what I'm trying to?
Thanks!
Vaclav Slavik
- --
PGP key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x465264C9
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+G2nvxDYa/UZSZMkRAjrLAJ94hkAt63hY+6BxucfJfUbfXgHkJACfeqD1
jwp7Hw4IZxV6HPFnZw/pgGU=
=7lhH
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-01-08 10:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-08 10:25 __attribute__((deprecated)) and inline constructors Vaclav Slavik
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).