www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/08/04/02:45:42

Message-ID: <3D4CCB5C.6040601@yahoo.com>
From: Jetset Willy <aaron_shetlar AT yahoo DOT com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.0) Gecko/20020530
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: how do I include stdio.h and stdarg.h?
Lines: 42
NNTP-Posting-Host: 12.239.155.179
X-Complaints-To: abuse AT attbi DOT com
X-Trace: sccrnsc02 1028442977 12.239.155.179 (Sun, 04 Aug 2002 06:36:17 GMT)
NNTP-Posting-Date: Sun, 04 Aug 2002 06:36:17 GMT
Organization: AT&T Broadband
Date: Sun, 04 Aug 2002 06:36:17 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello,

Does anyone know how to compile and run this program?

#include <stdio.h>
#include <stdarg.h>

void test(char *fmt, ...)
{
     va_list list;
     va_start(list, fmt);
     printf(fmt, list);
     va_end(list);
}

int main(int argc, char *argv[])
{
     test("Here I am: %s\n", "hello");
     return 0;
}

When I compile, I get the following message:

In file included from test.c:2:
c:/progra~1/djgpp/lib/gcc-lib/djgpp/3.1/include/stdarg.h:110: 
conflicting types
for `va_list'
c:/progra~1/djgpp/include/stdio.h:35: previous declaration of `va_list'

I hacked at it until I got it to compile by defining _VA_LIST_DEFINED 
right before including stdarg.h. When I ran it, however, it printed Here 
I am: (null), which makes me think this was not a good idea.

I've seen references to this problem on the web, but they were all for 
platforms other than windows. Most of the fixes I've seen suggested 
either don't apply or don't work.

Does anyone have any ideas?

Thanks,
Aaron

- Raw text -


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