🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2548

Re: Newsgroups: comp.lang.c,comp.lang.c++,comp.lang.c++.moderated,comp.lang.c.moderated

#2548
From: Dan Pop
Date: Mon, 08 Apr 1996 16:11
49 lines
2604 bytes
In <4k5vop$9ub@solutions.solon.com> jos@and.nl (Jos A. Horsmeier) writes:

>In article <4k1qi3$5ig@solutions.solon.com>, fred@genesis.demon.co.uk wrote:
>|>In article <4jtt2c$3eq@solutions.solon.com>
>|>           news@spar.ca "USENET News System" writes:
>
>|>/* Under the Microsoft Visual C++ 2.0 and 4.0 the following 
>|>    was observed. */
>|>
>|>typedef struct  { int a; int b; } *TA;
>|>typedef struct  { int a; int b; }  *TB;
>
>|Under ANSI C TA and TB have two distinct, incompatible types, they cannot
>|be directly assigned.
>
>I beg to differ; Have a look at the Standard:

As far as I can tell, compiler implementors treat TA and TB as
distinct, incompatible types.

>6.1.2.6 Compatible type and composite type
>
>'Moreover, two structure [ ... ] types declared in two separate 
>translation units are compatible if they have the same number of
>members, the same member names, and compatible member types; for 
>two structures, the members shall be in the same order [ ... ]'.

This paragraph doesn't say that two structure types declared in the
same translation unit can be compatible under a certain set of
circumstances.  Hence it cannot be used to support your position.

>The only thing that (still) bothers me, is the phrase 'two separate
>translation units' ... Compiler checks don't span translation units ...
>Does anyone has any idea what this phrase implies and what is meant
>by it?

I think I do.  Let's assume that FILE is defined as a structure in
<stdio.h>.  The text you quoted guarantees that the type FILE in
translation unit A is compatible with the type FILE in translation unit B,
assuming that <stdio.h> is part of both translation units.  Thus, you
can pass a FILE * argument in T.U. A to a function expecting a FILE *
argument which is defined in T.U. B without invoking undefined behaviour.

Dan
--
Dan Pop
CERN, CN Division
Email: danpop@mail.cern.ch 
Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
Technical Details
Message-ID: <4kbdrh$edm@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4jtt2c$3eq@solutions.solon.com> <4k1qi3$5ig@solutions.solon.com> <4k5vop$9ub@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: danpop@mail.cern.ch (Dan Pop)
Newsgroups: comp.lang.c.moderated
Subject: Re: Newsgroups: comp.lang.c,comp.lang.c++,comp.lang.c++.moderated,comp.lang.c.moderated
Date: 8 Apr 1996 11:11:29 -0500
Organization: CERN European Lab for Particle Physics
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4kbdrh$edm@solutions.solon.com>
References: <4jtt2c$3eq@solutions.solon.com> <4k1qi3$5ig@solutions.solon.com> <4k5vop$9ub@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com
X-Newsreader: NN version 6.5.0 #7 (NOV)