delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/02/04/12:10:35

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-3.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS
X-Spam-Check-By: sourceware.org
Message-ID: <4989CBF8.1000209@cwilson.fastmail.fm>
Date: Wed, 04 Feb 2009 12:10:16 -0500
From: Charles Wilson <cygwin AT cwilson DOT fastmail DOT fm>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.19) Gecko/20081209 Thunderbird/2.0.0.19 Mnenhy/0.7.5.666
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: "Incompatible" typedefs
References: <1233680809 DOT 17414 DOT 1298297091 AT webmail DOT messagingengine DOT com> <20090203171556 DOT GB12192 AT ednor DOT casa DOT cgf DOT cx> <4989511F DOT 4040200 AT cwilson DOT fastmail DOT fm> <4989AA1C DOT 70300 AT gmail DOT com>
In-Reply-To: <4989AA1C.70300@gmail.com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019