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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> 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

Is more used than you think. One reason is to add debug informations
(preprocessor is just a string replacement in the source while enums
carry information to the object level), the other is to avoid to clutter
preprocessor and avoid preprocessor sides effects.
Actually lot of system headers moved to enums using capital letters
to retain the old look and feel.

> enum { evol_mode_1 = 1, evol_mode_3 = 3, evol_mode_5  = 5 };

Won't work to solve the evol "issue".

> if that's useful in the rest of the code, but I'd rather not use enums
> for wmimax/wminext/evol
> 
> Christophe
> 

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]