Date: Fri, 10 May 96 09:34:03 +0200 From: wank AT ftth DOT uebemc DOT siemens DOT de (Rainer Wank) Message-Id: <9605100734.AA19401@malta> To: djgpp AT delorie DOT com Subject: vararg the second Cc: wank AT ftth DOT uebemc DOT siemens DOT de Hi folks, thank you for your answers, but there are still a few questions concerning my little test program: 1.) You wrote, ELI ZARETSKII, that what i have done is forbidden in ANSI C. What parts of my code are not ANSI conform ? Why does the djgpp compiler does not warn me, even if have used switches like -pedantic -ansi -Wall and so on ? Where can i read that the parts of the code you will mention are not ANSI conform ? 2.) S. Kagels' explanation (processors X86, little endian, ...) why my little program does not work as i expected seems to be plausible. Your suggestion to pass an unsigned int instead of an unsigned char after the predefined arguments fails. :-( Here is my modified test program and the output on stdout: #include #include unsigned int fg; void abc(int anzahl, char abc, ...) { va_list ap; va_start(ap, abc); fg = va_arg(ap, unsigned int); printf("\n\rErster variabler Parameter: %d", fg); va_end(ap); } void main(void) { abc((int) 10, (char) 10, (unsigned int) 51); } D:\GNU_V2>a Erster variabler Parameter: 1422080 --------------------------------------------- decimal: 1422080 hexadecimal: 15B300 decimal: 51 hexadecimal: 33 Even the passed parameter 51 decimal does not appear in the printed value. We also have the gcc on our SUN and so i tried both programs (the first and the modified) on the SUN. The first program fails but the second works on the SUN. After that i have tried a third program with djgpp gcc. I have changed the second parameter (unsigned char) into an unsigned int and it works :-) #include #include unsigned int fg; void abc(int anzahl, unsigned int abc, ...) { va_list ap; va_start(ap, abc); fg = va_arg(ap, unsigned int); printf("\n\rErster variabler Parameter: %d", fg); va_end(ap); } void main(void) { abc((int) 10, (unsigned int) 10, (unsigned int) 51); } D:\GNU_V2>a Erster variabler Parameter: 51 --------------------------------------------- Isn't it possible that the success of my third program has to do with the address of the passed arguments on the stack ? Thanx a lot and have a nice weekend ! Wank Rainer e-mail: wank AT ftth DOT uebemc DOT siemens DOT de