🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #16351

Re: File time problems, anyone have any ideas?

#16351
From: Ed Mulroy [TeamB]
Date: Sat, 17 May 2003 16:46
37 lines
2634 bytes
Bob,

Since wsprintf/printf/fprintf and company take a variable argument list, the
arguments are placed on the stack as 'promoted' types unless you explicitly
use a cast.  Therefore the values go in as 32 bit ones.  Unsigned short ints
(16 bits) are promoted to unsigned int so their numerical values are
unchanged.  Even were they to be promoted to signed int, none of the values
are candidates to even approach 32767, the largest short int, let alone
overflow to set the sign bit.

Again, thanks for your help.  I kept staring at it, looking for exotic
reasons for the problem, while you picked up on what the problem was
immediately.

.  Ed

> Bob Gonder wrote in message
> news:gmkccv04t9524h43nqd9dfifq58hvuvcc4@4ax.com...
>
> >> Should those be %2hd and %4hd (words, not 16bit ints)?
> >
> >It doesn't matter.  The d is 32 bits and since the numbers
> >are dates and times, none of them approaches setting the
> >sign bit.
>
> Yeah, but they are 16 bit values. In the old days, the compiler
> would have pushed the 16bit values and the library would have
> interpreted them as 32bit (combining two 16bit values).  I guess
> today, the 16bit values are pushed as 32bit, and the library
> knows that reguardless of the stated size, they are always
> 32bit  on the stack (unless they are 64 <g>).
> Also, one might envision this happening:
> mov cx,st.wMINUTE
> push ecx
> call printf
> What's in the upper 16bits?  With %hd I would expect the library
> to handle it correctly (ignore the upper 16).
Technical Details
Message-ID: <3ec66792$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3ec55f4f$1@newsgroups.borland.com> <g9racvc3j0vp8jsm2ttndnhtqj03mmaq6d@4ax.com> <3ec584e9$1@newsgroups.borland.com> <gmkccv04t9524h43nqd9dfifq58hvuvcc4@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,bcd78c7fec4f306a
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-05-17 09:56:31 PST
From: "Ed Mulroy [TeamB]" <ed@mulroyREMOVETHESECHARS.org>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3ec55f4f$1@newsgroups.borland.com> <g9racvc3j0vp8jsm2ttndnhtqj03mmaq6d@4ax.com> <3ec584e9$1@newsgroups.borland.com> <gmkccv04t9524h43nqd9dfifq58hvuvcc4@4ax.com>
Subject: Re: File time problems, anyone have any ideas?
Date: Sat, 17 May 2003 12:46:38 -0400
Lines: 39
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 24.74.175.102
Message-ID: <3ec66792$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1053190034 24.74.175.102 (17 May 2003 09:47:14 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail