Path: utzoo!attcan!uunet!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.unix.wizards Subject: Re: unsigned sizeof() Message-ID: <12141@smoke.BRL.MIL> Date: 14 Feb 90 17:37:39 GMT References: <6042@arctic.nprdc.arpa> Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 16 In article <6042@arctic.nprdc.arpa> stanonik@nprdc.navy.mil (Ron Stanonik) writes: >Yes, 2nd edition K&R says the result of sizeof is unsigned (though >it also says the type is implementation-defined, p204, which I find >contradictory). Why though? Why make sizeof unsigned? sizeof was changed to produce an unsigned int somewhere around 1980. The main reason was that a signed int was simply unable to express the size of some C data objects encountered in split-I&D PDP-11 applications. It is also logically unsigned anyway. >Sorry if this is old news. It was a surprise to us; ie, sizeof >on our suns and vax (4bsd) returns signed. Well, their C compilers were based on old, decrepit versions of PCC. And non-portable programs abound, so you really shouldn't be surprised that you encountered one.