🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#2539
From: Michael Smith
Date: Sat, 06 Apr 1996 15:02
53 lines
2400 bytes
USENET News System wrote:
 > 
 > /* 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;
 > 
 > void
 > f( TA x, TB y )
 > {
 >   f ( y, x);            /* This compiles fine */
 > }
 > 
 > 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? */
 > 

The Microsoft compilers are generally liberal, and often let you get away 
with things that you ought not.  Why does it object on the second 
example?  

Are "int"s 16 or 32 bits in VC++ 2.0?  

If they are 32 bits, it may be that the compiler objects because the 
structs are of different sizes.  If they are 16 bits, it may be a problem 
with byte alignment.

I compiler the code under VC++ 1.0 and it compiled OK but gave warnings 
about "Inderection to different types" in both subroutines.

I suppose that a more interesting question is "what are you actually 
trying to achieve?  There are probably many ways to work around what you 
are trying to do, but a little context would help.

-- 
#####################################################################
Michael Smith                                       msmith@mpx.com.au
Emmenjay Consulting                 http://www.hutch.com.au/~emmenjay
#####################################################################
Technical Details
Message-ID: <4k6123$amu@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4jtt2c$3eq@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: Michael Smith <msmith@mpx.com.au>
Newsgroups: comp.lang.c.moderated
Subject: Re: Newsgroups: comp.lang.c,comp.lang.c++,comp.lang.c++.moderated,comp.lang.c.moderated
Date: 6 Apr 1996 09:02:27 -0600
Organization: Emmenjay Consulting
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4k6123$amu@solutions.solon.com>
References: <4jtt2c$3eq@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com
X-Mailer: Mozilla 2.0 (Win16; I)