From: Vaclav Slavik <vaclav.slavik@matfyz.cz>
To: gcc-help@gcc.gnu.org
Subject: __attribute__((deprecated)) and inline constructors
Date: Wed, 08 Jan 2003 10:25:00 -0000 [thread overview]
Message-ID: <200301080059.43059.vaclav.slavik@matfyz.cz> (raw)
-----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-----
reply other threads:[~2003-01-08 10:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200301080059.43059.vaclav.slavik@matfyz.cz \
--to=vaclav.slavik@matfyz.cz \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).