[Spice-devel] [spice-common 01/14] quic: Use #define rather than static const int

Christophe Fergeau cfergeau at redhat.com
Tue Jul 18 10:11:13 UTC 2017


On Wed, Jul 05, 2017 at 06:59:46AM -0400, Frediano Ziglio wrote:
> 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.

Did not answer to that one, but a #define for constants is more common than using
enums this way. I'd be fine with
enum { evol_mode_1 = 1, evol_mode_3 = 3, evol_mode_5  = 5 };
if that's useful in the rest of the code, but I'd rather not use enums
for wmimax/wminext/evol

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/20170718/c712a7d3/attachment-0001.sig>


More information about the Spice-devel mailing list