From: "Edd Dawson" Newsgroups: comp.os.msdos.djgpp References: <%kET9.17088$q67 DOT 14211 AT news-binary DOT blueyonder DOT co DOT uk> <1042224128 DOT 205850 AT queeg DOT ludd DOT luth DOT se> Subject: Re: stdarg.h problem(s)? Lines: 134 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: <0oNT9.5250$CZ5.4796@news-binary.blueyonder.co.uk> Date: Sat, 11 Jan 2003 04:54:21 -0000 NNTP-Posting-Host: 80.192.26.95 X-Complaints-To: abuse AT blueyonder DOT co DOT uk X-Trace: news-binary.blueyonder.co.uk 1042260604 80.192.26.95 (Sat, 11 Jan 2003 04:50:04 GMT) NNTP-Posting-Date: Sat, 11 Jan 2003 04:50:04 GMT Organization: blueyonder (post doesn't reflect views of blueyonder) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Martin Str|mberg" wrote in message news:1042224128 DOT 205850 AT queeg DOT ludd DOT luth DOT se... > First note that I'm not an expert on va_lists. > Noted. Makes two of us :) > Edd Dawson wrote: > : I am currently running into problems when making functions of an arbitrary > : number of arguments in C/C++. > : I am using DJGPP version 3.2. Here's a reduced version of the code I'm > : trying to work with: > > : //Code starts here: test.c > : #include > : #include > > : void Warning(char *warningstring, ...) > : { > : va_list arg_list; > : va_start(arg_list, warningstring); > : printf("WARNING: "); > : printf(warningstring, arg_list); > : va_end(arg_list); > : return; > : } > > > : main() > : { > : Warning("This is a %s.\n", "test"); > : } > : //Code ends here > > : Firstly, I'm pretty sure what i've got there is ok and without error - > : although I hope someone will prove me wrong in a way... =) > : Well, here's what happens.... > : If use the following command line: > > : gcc test.c -o test.exe > > : I get zero compilation errors but this is the output when i run the program: > > How about warnings? Add "-Wall". > If i turn on all warnings, it doesn't say anything that relates to the problem, only moans about the control reaching the end of non-void function (main). Also warns return type defaults to 'int' in function Warning. > : WARNING: This is a !_. > I have now tried compiling this with Borland's BCC32 and also MinGW and i get the exact same output. So my code is wrong it seems. Anyone know what's wrong exactly? > : or something similar. Ok, well that's the first problem. Second one is when > : i use this command line instead: > > : gpp test.c -o test.exe > : (gpp rather than gcc) > > : I get the following compilation errors: > > : In file included from test.c:2: > : c:/djgpp/lib/gcc-lib/djgpp/3.2/include/stdarg.h:110: conflicting types for ` > : typedef char*va_list' > : c:/djgpp/include/stdio.h:35: previous declaration as `typedef void*va_list' > > Have you read the readme file that came in gcc*b.zip. (I don't > remember its name but it starts or ends with "readme"). You need to > patch the header file, IIRC. The only thing I've managed to find is some blurb at the bottom of readme.DJGPP - some preprocessor directives: --- include/sys/djtypes.h~1 Tue Dec 14 06:56:16 1999 +++ include/sys/djtypes.h Mon Feb 4 16:20:40 2002 @@ -12,7 +12,12 @@ #define __DJ_ssize_t typedef int ssize_t; #define __DJ_time_t typedef unsigned int time_t; #define __DJ_uid_t typedef int uid_t; + +#if __GNUC__>=3 +#define __DJ_va_list typedef __builtin_va_list va_list; +#else #define __DJ_va_list typedef void *va_list; +#endif #if defined(__cplusplus) && ( (__GNUC_MINOR__ >= 8 && __GNUC__ == 2 ) || __GNUC__ >= 3 ) /* wchar_t is now a keyword in C++ */ Is that what you mean? If so what do I do with this? :) I'm struggling to find any other related information to this in the file or any others... Help! :) > : So then I tried renaming c:/djgpp/lib/gcc-lib/djgpp/3.2/include/stdarg.h to > : something else for the time being. It then compiled fine, but then same > > No. You should never rename anything (unless instructed by e. g. a > readme to do so)! You're just breaking things. > > Why is it that people think this is a good idea? I'd sure like to > know. Broken is broken. If i change it, the worse that can happen is that it's still broken. Besides the change was only temporary as stated. I didn't know that changing data stored on my own computer could be so offensive to someone else. I will try harder in future. I think I'll try deleting DJGPP and reinstalling from scratch as I may have missed something when trying to remove everything from my system last time around. Regardless, my code appears to be incorrect. Can anyone help? > > Right, > > MartinS Edd