[Spice-devel] [protocol] macros: Use GLib's G_DEPRECATED macro if available

Christophe Fergeau cfergeau at redhat.com
Wed Nov 23 10:24:29 UTC 2016


On Mon, Nov 21, 2016 at 07:13:42PM +0100, Francois Gouget wrote:
> On Wed, 9 Nov 2016, Christophe Fergeau wrote:
> [...]
> > I believe all of these were more or less directly imported from glib.
> > Grepping around, I could only find SPICE_GNUC_VISIBLE, SPICE_GNUC_NORETURN,
> > SPICE_GNUC_UNUSED, SPICE_GNUC_PRINTF and SPICE_GNUC_DEPRECATED being
> > used. At this point, I'd just make sure the other ones emit a (compile
> > time) warning when they are used unless some magic define is set, and
> > drop them after a while.
> 
> I'm not sure how to do that:
>  * If I'm not mistaken a #warning directive must be used alone on a 
>    line but this is not how __attribute__ is used. Furthermore I doubt 
>    #warning would even work if put inside a macro and putting it inside 
>    the #ifdef would warn about the macro being defined, not about it 
>    being used.
> 
>  * I could define the macro to something like 'define FOO to use this 
>    macro' but this would generate a compilation error, not a compilation 
>    warning.

Ah, good point, forgot that they are macros, and that G_DEPRECATED can't
be used with them. Given that most of them go with function
prototypes, we could do something like

#define SPICE_GNUC_PURE  __attribute__ ((__pure__, warning("deprecated, use -DFOO or GG_GNUC_PURE instead")))

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20161123/d46d4471/attachment.sig>


More information about the Spice-devel mailing list