Article View: comp.std.c
Article #2091Re: Typedefing built in data types
From: Norman Diamond
Date: Thu, 05 Nov 1992 02:05
Date: Thu, 05 Nov 1992 02:05
34 lines
2622 bytes
2622 bytes
In article <1992Nov3.093404.9124@odin.diku.dk> jkut@diku.dk (Jonatan Kutchinsky) writes: >we simulate a Motorola 68000 processor. We decided decided to typedef the >built in types char, short, and long to new names, BYTE, WORD, and LWORD. The standard permits these typedefs. The standard does not rule on style. >The reason why we want to do this, is that we want to emphasize the >difference between the data used to control the simulation, etc., >and the data that the simulated microprocessor is processing. We are using >ints, chars and longs to do everything else than containing data from the >simulated memory and registers, and while it is processed by instructions. I personally think that looks very nice. Some famous programs have similar typedefs for certain kinds of portability, and some people have wished that other famous programs would have similar typedefs for data formats that go over a network, etc. But this topic belongs in alt.religion.computers. >The problem is that our teacher has the opinion that this use of typedef is >a bad thing, and that it makes the program less readable when you do not >know that LWORD really stands for long, without looking in the header file. It is true that you don't know that LWORD really stands for long, without looking in the header file. Also you don't know how many bits long has, without looking in the C implementation's manuals. You have to read or else hope that it happens to be the correct length for the simulated processor. This topic belongs in, I don't know, maybe comp.software-eng. Your teacher is allowed to believe that this use of typedef is a bad thing (at least, I think Danish laws allow freedom of belief :-) Followups are directed to alt.religion.computers. -- Norman Diamond diamond@jit081.enet.dec.com If this were the company's opinion, I wouldn't be allowed to post it. "It's been a lovely recession."
Technical Details
Message-ID:
<Bx80HL.GGC@jrd.dec.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!haven.umd.edu!decuac!pa.dec.com!nntpd2.cxo.dec.com!nntpd.lkg.dec.com!e2big.mko.dec.com!jrdzzz.jrd.dec.com!jit345.bad.jit.dec.com!diamondReferences:
<1992Nov3.093404.9124@odin.diku.dk>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!haven.umd.edu!decuac!pa.dec.com!nntpd2.cxo.dec.com!nntpd.lkg.dec.com!e2big.mko.dec.com!jrdzzz.jrd.dec.com!jit345.bad.jit.dec.com!diamond From: diamond@jit345.bad.jit.dec.com (Norman Diamond) Subject: Re: Typedefing built in data types Message-ID: <Bx80HL.GGC@jrd.dec.com> Followup-To: alt.religion.computers Sender: usenet@jrd.dec.com (USENET News System) Nntp-Posting-Host: jit345 Reply-To: diamond@jit.dec.com (Norman Diamond) Organization: Digital Equipment Corporation Japan , Tokyo References: <1992Nov3.093404.9124@odin.diku.dk> Date: Thu, 5 Nov 1992 02:05:44 GMT Lines: 34