[Spice-devel] [spice-common 01/14] quic: Use #define rather than static const int
Frediano Ziglio
fziglio at redhat.com
Wed Jul 5 10:59:46 UTC 2017
In my stash pile I have these:
diff --git a/common/quic.c b/common/quic.c
index c188ed2..aa0d8ab 100644
--- a/common/quic.c
+++ b/common/quic.c
@@ -173,13 +173,13 @@ struct Encoder {
};
/* target wait mask index */
-static const int wmimax = DEFwmimax;
+enum { wmimax = DEFwmimax };
/* number of symbols to encode before increasing wait mask index */
-static const int wminext = DEFwminext;
+enum { wminext = DEFwminext };
/* model evolution mode */
-static const int evol = DEFevol;
+enum { evol_mode_1 = 1, evol_mode_3 = 3, evol_mode_5 = 5, evol = DEFevol };
/* bppmask[i] contains i ones as lsb-s */
static const unsigned long int bppmask[33] = {
Seems to work and enums are compile time constants.
Frediano
----- Original Message -----
> From: "Christophe Fergeau" <cfergeau at redhat.com>
> To: spice-devel at lists.freedesktop.org
> Sent: Wednesday, July 5, 2017 9:20:35 AM
> Subject: [Spice-devel] [spice-common 01/14] quic: Use #define rather than static const int
>
> quic.c is checking at compile-time that 'evol' is 1, 3 or 5. This is a
> constant, so a static check should be good, but my compiler (gcc 7.1.1)
> is unable to know 'evol' value at compile-time. Since the removal of
> spice_static_assert in favour of SPICE_VERIFY, this causes a
> compile-time failure.
> ---
> common/quic.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/common/quic.c b/common/quic.c
> index c188ed2..b7d8347 100644
> --- a/common/quic.c
> +++ b/common/quic.c
> @@ -179,7 +179,7 @@ static const int wmimax = DEFwmimax;
> static const int wminext = DEFwminext;
>
> /* model evolution mode */
> -static const int evol = DEFevol;
> +#define evol DEFevol
>
> /* bppmask[i] contains i ones as lsb-s */
> static const unsigned long int bppmask[33] = {
> --
> 2.13.0
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
>
More information about the Spice-devel
mailing list