delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/01/11/05:45:14

From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: stdarg.h problem(s)?
Date: Sat, 11 Jan 2003 09:46:00 +0000
Lines: 53
Message-ID: <3E1FE7D8.6490E6C3@phekda.freeserve.co.uk>
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> <0oNT9.5250$CZ5 DOT 4796 AT news-binary DOT blueyonder DOT co DOT uk>
NNTP-Posting-Host: 62.136.44.234
Mime-Version: 1.0
X-Trace: news8.svr.pol.co.uk 1042280301 2011 62.136.44.234 (11 Jan 2003 10:18:21 GMT)
NNTP-Posting-Date: 11 Jan 2003 10:18:21 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586)
X-Accept-Language: de,fr
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello.

Edd Dawson wrote:
[snip]
> > Edd Dawson <hotcakes AT planetquake DOT com> 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 <stdio.h>
> > : #include <stdarg.h>
> >
> > : void Warning(char *warningstring, ...)
> > : {
> > :    va_list arg_list;
> > :    va_start(arg_list, warningstring);
> > :    printf("WARNING: ");
> > :    printf(warningstring, arg_list);
> > :    va_end(arg_list);
> > :    return;
> > : }

Try using vprintf instead. Instead of using:

    printf(warningstring, arg_list);

use:

    vprintf(warningstring, arg_list);

Apart from that, the code looks fine. (I haven't tried compiling it.) You may
want to look at this info page, if you want gcc to produce printf-style format
warnings:

    info gcc 'c extensions' 'function attributes'

[snip]
> 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.

I don't think you need to go that far. Try reinstalling djdev203. A refreshed
version of that was released, which should fix the problem above.
 
> Regardless, my code appears to be incorrect. Can anyone help?

Hope that helps. Regards,

-- 
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]

- Raw text -


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