This is the mail archive of the cygwin mailing list for the Cygwin 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: "Incompatible" typedefs


Dave Korn wrote:
> Charles Wilson wrote:
> 
>> I would have thought that these two:
>>
>> typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
>> typedef unsigned short int uint16_t;
>>
>> are very different. 
> 
>   I wouldn't have.  They're both unsigned, they're both integers, and
> they're both 16 bits.  HImode is the internal GCC type that gets mapped
> to C short ints.  Why do you think they would differ?

But on cygwin, unsigned long is unsigned, it is an integral type, and
both 'unsigned long' and 'unsigned int' are 32 bits. Under the hood,
they are identical.

But the compiler complained.

What you describe is exactly the "compiler magic" I was referring to:
"unsigned int __attribute__ ((__mode__ (__HI__)))" := unsigned short int
They "look different" but aren't.

>> I'm not sure what useful conclusions we can draw from looking at how
>> linux does it, Or maybe I just need some sleep.
> 
>   I think we just add 'int' where it's missing from longs and long longs
> and we're done.  And there should be a handy test-case to reduce from
> the octave sources.

As Corinna pointed out, this is moot. Fixed in 1.7.

But, at the risk of extending this thread -- I do have a question. Is
there really a difference between

short    vs.    short int
long     vs.    long int
unsigned vs.    unsigned int
signed   vs.    signed int
(etc, other combinations of modifiers with and without 'int')

Your argument seems to imply that there is. I always thought that the
'int' was implied when only the size (or signedness) was specified, and
that the types were exactly identical. No? Reference, please? Is this
buried in K&R somewhere I missed?

--
Chuck

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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