GNOME Bugzilla – Bug 614965
Add new G_GNUC_DEPRECATED_FOR macro
Last modified: 2011-02-18 16:06:55 UTC
apparently, gcc 4.5 will add an optional argument for the deprecated __attribute__. this should allow better error message reporting when compiling a project using deprecated functions/types. we should probably add a new G_GNUC_DEPRECATED_FOR macro defined as: G_GNUC_DEPRECATED_FOR(t) which would expand to: __attribute__ ((deprecated ("Use ##t instead"))) this way we could have: void my_foo_bar (MyFoo *foo, gint bar) G_GNUC_DEPRECATED_FOR (gtk_foo_set_bar); giving out an error message like: warning: ‘gtk_foo_bar’ is deprecated: Use gtk_foo_set_bar instead the fallback for previous versions of gcc is #define G_GNUC_DEPRECATED_FOR(s) G_GNUC_DEPRECATED the patch is trivial, and I'll be able to do it as soon as I have a gcc 4.5 version to play with.
just for reference, the upstream bug is: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43666
Created attachment 158052 [details] [review] Add G_GNUC_DEPRECATED_FOR macro It would be good, error reporting-wise, to be able to signal which function should be used instead of a deprecated one. GCC 4.5 added an optional "message" payload to the deprecated attribute, so that: void f1 (void) __attribute__((deprecated("Use f2 instead"))); Will expand to: warning: f1 is deprecated: Use f2 instead Instead of just printing: warning: f1 is deprecated Since we already have a G_GNUC_DEPRECATED macro we should provide a G_GNUC_DEPRECATED_FOR macro defined as: G_GNUC_DEPRECATED_FOR(bar) Which would expand the deprecation message to "Use bar instead" automatically. The deprecation message should probably be similar to what we use in gtk-doc to match up with the documentation.
Comment on attachment 158052 [details] [review] Add G_GNUC_DEPRECATED_FOR macro nice
Attachment 158052 [details] pushed as 38e2273 - Add G_GNUC_DEPRECATED_FOR macro