Date: Mon, 22 Sep 1997 09:24:40 +0300 (IDT) From: Eli Zaretskii To: Brett Porter cc: DJGPP Subject: Re: %d In-Reply-To: <199709220431.OAA28739@rabble.uow.edu.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Mon, 22 Sep 1997, Brett Porter wrote: > Just a BTW, does anyone know whether %d looks for a 32-bit int or a 16-bit > int in djgpp? int is 32-bit in DJGPP, so %d looks for a 32-bit int. > I originally thought it would take a 32-bit, but I notice that > there is a long modifier %l, but no short modifier. That's for the same reason that there's only one %f format for printing both floats and doubles: ANSI C requires that all shorts are promoted to ints when passed to functions with variable argument lists. So, even if you pass a short, `printf' gets an int, and doesn't need a special format for shorts. > I haven't had any problems yet, but if I pass it a 16-bit short and it > expects a 32-bit and then I try and pass it some more arguments I may (in > the future) get a crash, so I thought I'd check it out now. Relax, you will *never* get a crash with `printf' because of this. In fact, altough ANSI C permits it, I'd advise against declaring *any* functions (even with constant argument lists) with shorts or floats as one of the arguments; I suggest to always use ints and doubles instead.