This is the mail archive of the cgen@sourceware.org mailing list for the CGEN project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Make large enum constants unsigned


Hi -

> > > >      (string-append "(signed int)" (number->string (cadr e)))
> > > [...]
> > > how would that be better than?
> > >       (string-append (number->string (cadr e)) "U")
> > 
> > It would be a closer match to expressing our desire to match C enum
> > typing, but I'd be fine with "U" suffixing too.
> 
>  TBH I don't understand what you mean here, a C compiler is free to choose 
> from `char', `int' and `unsigned int' as the underlying (compatible) type 
> of an enumeration as long as the type can represent all the member values 
> defined.  [...]

I'm not a language lawyer, and in different levels of the language
this has changed, but my understanding is that to be most compatible,
the enumerators (the given literals) need to be 'int's.  (It's a
separate question as to what type the compiler would allocate to an
enum FOO variable.)


> over the `unsigned int' type here?  If this is used to produce a bit mask, 
> which I gather it is, then I find using an unsigned type more natural.

I see what you mean.


- FChE


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]