[Spice-devel,protocol] macros: Update SPICE_GNUC_DEPRECATED for MSVC

Submitted by Francois Gouget on Oct. 28, 2016, 9:57 a.m.

Details

Message ID E1c03un-00023g-3z@amboise
State New
Headers show
Series "macros: Use GLib's G_DEPRECATED macro if available" ( rev: 2 ) in Spice

Not browsing as part of any series.

Commit Message

Francois Gouget Oct. 28, 2016, 9:57 a.m.
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
---

This is an alternative take on the previous patch: instead of reusing 
the GLib macro it just duplicates its logic.

GLib approach
-------------

Pros: - Automatic support for whichever platforms GLib supports.
      - Simple.
Cons: - If the project uses GLib it might as well use the GLib macros 
        directly.

This approach
-------------

Pros: - Support for non-gcc compilers is available even if the project 
        does not use GLib.
Cons: - Duplicates GLib's code.


As before the same treatment could be applied to a bunch of other 
macros.


 spice/macros.h | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/spice/macros.h b/spice/macros.h
index a0413f3..0df3da4 100644
--- a/spice/macros.h
+++ b/spice/macros.h
@@ -80,6 +80,8 @@ 
 
 #if    __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
 #define SPICE_GNUC_DEPRECATED  __attribute__((__deprecated__))
+#elif  defined(_MSC_VER) && (_MSC_VER >= 1300)
+#define SPICE_GNUC_DEPRECATED  __declspec(deprecated)
 #else
 #define SPICE_GNUC_DEPRECATED
 #endif /* __GNUC__ */

Comments

On Fri, Oct 28, 2016 at 11:57:33AM +0200, Francois Gouget wrote:
> Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
> ---
> 
> This is an alternative take on the previous patch: instead of reusing 
> the GLib macro it just duplicates its logic.

Why alternative? I think I would take both patches ;) We'd have a MSVC
fallback when glib is not in use, so an improvement from before.

Christophe