Article View: comp.bugs.2bsd
Article #15%x vs. %X vs %lx (was: NTP 3.4.1.6 porting problems +FIX)
From: Steve Summit
Date: Sat, 29 Jul 1989 06:08
Date: Sat, 29 Jul 1989 06:08
16 lines
1289 bytes
1289 bytes
In article <34005@wlbr.IMSD.CONTEL.COM> sms@wlv.imsd.contel.com (Steven M. Schultz) writes:
> In porting NTPD and friends I uncovered a number of
> problems, all related to being on a machine where
> sizeof (int) != sizeof (long). Using %X to print
> the value of ntohs()...
The old code was doubly wrong; %X shouldn't be used to print a
long. %X, %D, %U, and %O no longer imply a long argument; long
arguments are uniquely indicated with the 'l' modifier: %lx,
%ld, %lu, and %lo. %X now means "hexadecimal, but use ABCDEF
instead of abcdef." The other three are undefined. (The code
presumably worked to print the long result of ntohs() on a
machine with sizeof(int) == sizeof(long).)
Steve Summit
scs@adam.pika.mit.edu
Technical Details
Message-ID:
<13110@bloom-beacon.MIT.EDU>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!bloom-beacon!adam.pika.mit.edu!scsReferences:
<34005@wlbr.IMSD.CONTEL.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!bloom-beacon!adam.pika.mit.edu!scs From: scs@adam.pika.mit.edu (Steve Summit) Newsgroups: comp.bugs.2bsd Subject: %x vs. %X vs %lx (was: NTP 3.4.1.6 porting problems +FIX) Message-ID: <13110@bloom-beacon.MIT.EDU> Date: 29 Jul 89 06:08:30 GMT References: <34005@wlbr.IMSD.CONTEL.COM> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: scs@adam.pika.mit.edu (Steve Summit) Lines: 16