delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/02/04/19:08:02

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: <498A2DD3.7000402@cwilson.fastmail.fm>
Date: Wed, 04 Feb 2009 19:07:47 -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> <4989CBF8 DOT 1000209 AT cwilson DOT fastmail DOT fm> <loom DOT 20090204T183338-593 AT post DOT gmane DOT org>
In-Reply-To: <loom.20090204T183338-593@post.gmane.org>
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

Eric Blake wrote:
> The difference you are running into is the fact that 'int' and 'long int' (or 
> alternately spelled, 'int' and 'long') are distinct types, even if they both 
> occupy 32 bits and are both signed. 

Right. That was my understanding [*] which is why I assumed the cygwin
headers (in their 1.5 incarnation) needed some adjustment. But 1.7
already has the fix, so...

[*] "But on cygwin, unsigned long is unsigned, it is an integral
type,..." was my counterfactual argument against Dave's assertion that

typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
typedef unsigned short int uint16_t;

are somehow obviously identical. (They ARE identical, but it is
unobvious). Spellings matter. Except when they don't.

>> [Dave's argument elided]
>> 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?

> How about C99 6.2.5 Types:
[snipped]
> and 6.7.2 Type specifiers:
[snipped]

These both agree with my earlier understanding. But then I still don't
understand how Dave's "fix" would fix anything:

Changing:
typedef long int32_t
typedef unsigned long uint32_t

To:
typedef long int int32_t
typedef unsigned long int uint32_t

(e.g as Dave said, "just add 'int' where it's missing" -- that is, ADD,
 not replace)

is a case of changing the spelling without changing the meaning at all;
that change would have zero effect and the definition of uint32_t would
STILL be different than u_int32_t, an "unsigned int". Right?

> And with this knowledge, you then get to play with what gcc means by
> 
>>> typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
>>> typedef unsigned short int uint16_t;
> 
> They are based on two different base types (unsigned int vs. unsigned short 
> int), but the presence of __attribute__ means that you are outside the realm of 
> C99, so it is up to the compiler whether u_int16_t is effectively the same 
> class as 'unsigned short int' or whether it behaves more like an 'unsigned int' 
> truncated to 16 bits.  And that's where I don't know the right answer.

Yep. Deep dark compiler magic.

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