delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/09/03:19:06

Message-Id: <199605090712.DAA29376@delorie.com>
Date: Thu, 09 May 96 10:04:32 LIT
From: Martynas Kunigelis <martynas DOT kunigelis AT VM DOT KTU DOT LT>
Subject: Re: vararg
To: Justin Ward <justin AT yoss DOT canweb DOT net>,
DJGPP mailing list <djgpp AT delorie DOT com>
In-Reply-To: Your message of Wed, 8 May 1996 15:29:15 -0400 (EDT)

On Wed, 8 May 1996 15:29:15 -0400 (EDT) you said:
>
>
>On Wed, 8 May 1996, Rainer Wank wrote:
>
>> void abc(int anzahl, unsigned char abc, ...)
>> {
>>  va_list ap;
>>  va_start(ap, abc);
>>  fg = va_arg(ap, unsigned char);
>>  printf("\n\rErster variabler Parameter: %d", fg);
>>  va_end(ap);
>> }
>
>You are taking fg as a char, but printing it as an int. With djgpp, and
>int is 4 bytes and a char is either two or one (I think), depending on
>whether you're compiling as C or C++. On the sun and on bc 3.1, a char
>and an int are both 2 bytes it seems. I can't say for sure regarding the
>sun, but I know this is the case regarding bc. Anyway, just rewrite your
>printf using %c instead of %d and everything will be fine.
>
>Justin

You're *wrong*. `char' is one byte almost *everywhere* except non-ASCII
systems. BC 3.1 *definetly* uses ONE byte to store a char variable. Also
there is no difference in `char' size between C and C++.

Martynas

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019