This is the mail archive of the gcc-help@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]
Other format: [Raw text]

__attribute__((deprecated)) and inline constructors


-----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-----


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