delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/01/19/18:27:17

From: Geed AT kong DOT net (exe)
Subject: B20: typedef bug?
19 Jan 1999 18:27:17 -0800 :
Message-ID: <000701ba00e6$4826f260$9d6b1581.cygnus.gnu-win32@d110-1007.rit.edu>
Mime-Version: 1.0
To: <gnu-win32 AT cygnus DOT com>

This is a multi-part message in MIME format.

------=_NextPart_000_0004_01BA00E6.467BB360
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

typedef char bmp_t[480][640];

void main() {
  bmp_t*bmp=3Dnew bmp_t;
}

results in...

test.cc: In function `int main(...)':
test.cc:4: initialization to `char (*)[480][640]' from `char (*)[640]'

This occures in 3 different compilers (including non gnu-cpp), so mabey =
typedef was not intended to be used this way.
It does appear to be a bogus error though.

the only good workaround I found is to create a macro that typecasts =
another type

#define new2(a) ((a*)(new char[sizeof(a)]))

bmp_t*bmp=3Dnew2 (bmp_t);



Louie Gosselin

------=_NextPart_000_0004_01BA00E6.467BB360
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.3110.7"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 size=3D2>typedef char =
bmp_t[480][640];</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>void main() {<BR>&nbsp; =
bmp_t*bmp=3Dnew=20
bmp_t;<BR>}</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>results in...</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>test.cc: In function `int=20
main(...)':<BR>test.cc:4: initialization to `char (*)[480][640]' from =
`char=20
(*)[640]'<BR></FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>This occures in 3 different =
compilers (including=20
non gnu-cpp), so mabey typedef was not intended to be used this=20
way.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>It does appear to be a bogus error=20
though.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>the only good workaround I found is =
to create a=20
macro that typecasts another type</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>#define new2(a) ((a*)(new=20
char[sizeof(a)]))<BR></FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>bmp_t*bmp=3Dnew2 =
(bmp_t);<BR></FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>Louie =
Gosselin</FONT></DIV></BODY></HTML>

------=_NextPart_000_0004_01BA00E6.467BB360--


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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