Article View: comp.lang.c.moderated
Article #2511Re: Newsgroups: comp.lang.c,comp.lang.c++,comp.lang.c++.moderated,comp.lang.c.moderated
From: Lawrence Kirby
Date: Fri, 05 Apr 1996 00:46
Date: Fri, 05 Apr 1996 00:46
47 lines
2143 bytes
2143 bytes
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.
>void
>f( TA x, TB y )
>{
> f ( y, x); /* This compiles fine */
This is a constraint violation and a diagnostic is required. I tried this
with gcc and and old Microsoft version 6 compiler supplied with SCO Unix
and both generate the required diagnostic. Are you sure you're compiling in a
full ANSI C conformant mode?
>}
>
>typedef struct tagA { int a; int b; } *UA;
>typedef struct tagB { float ttt; } *UB;
>
>void
>g( UA x, UB y )
>{
> g ( y, x); /* This does not */
> /* error C2664: 'g' :
> cannot convert parameter 1 from 'struct tagB*' to 'struct tagA*' */
>}
>
>/* My question is this: Why does the function f compile without errors?
> I've tried this code in gcc and I get an error in both functions.
> Who is right here? I suspect gcc is correct, but is Microsoft's
> implemention allowable in the standard also? */
No, it isn't, at least not with the compiler options you used.
--
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
Technical Details
Message-ID:
<4k1qi3$5ig@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4jtt2c$3eq@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: Lawrence Kirby <fred@genesis.demon.co.uk> Newsgroups: comp.lang.c.moderated Subject: Re: Newsgroups: comp.lang.c,comp.lang.c++,comp.lang.c++.moderated,comp.lang.c.moderated Date: 4 Apr 1996 18:46:59 -0600 Organization: none Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4k1qi3$5ig@solutions.solon.com> References: <4jtt2c$3eq@solutions.solon.com> Reply-To: fred@genesis.demon.co.uk NNTP-Posting-Host: solutions.solon.com X-NNTP-Posting-Host: genesis.demon.co.uk X-Newsreader: Demon Internet Simple News v1.27 X-Mail2News-Path: genesis.demon.co.uk