[lug] varargs.h stdarg.h

Gary Hodges Gary.Hodges at noaa.gov
Mon May 2 16:47:36 MDT 2005


I realized I never followed up on this with the group, though I don't 
really have much to add...  My nephew, who is subscribed to this list, 
offered to take a look at the code and was able to get it to compile. 

Gary

D. Stimits wrote:

> Gary Hodges wrote:
>
>> I'm trying to get some C code to compile and have run into an issue.  
>> It seems varargs.h is no longer supported and a compile error 
>> suggested changing to stdarg.h.  I've done that, but it results in a 
>> bunch of errors that mostly seem syntax related.  I've tried changing 
>> code based on a few searches, but being almost completely C 
>> illiterate, I'm not making much progress.  The entire thing is only 
>> about 50 lines.  I'm including a short section that is producing some 
>> errors and am hoping I can get some guidance (Lines 25-39).  I'm told 
>> this compiled fine with RHL 7.0.
>> int xprintf( va_alist )
>>  va_dcl
>> {
>>  va_list args;
>>  FILE    *fp;
>>  int     line;
>>  char    *format, *file, out_str[512];
>>
>>  va_start(args);
>>
>>  /* get file pointer */
>>  fp = va_arg(args, FILE *);
>>  if(fp == NULL)
>>    return(0);
>
> ...
>
> Don't know if this will help or not, but take a look at 
> /usr/include/ansidecl.h.
>
> It appears that you're using really old code (the declaration style 
> itself is something I haven't seen anyone use in years) that is 
> "traditional" C but not ANSI C. By default I believe gcc on recent 
> distros probably expects ANSI C, since __STDC__ is likely there by 
> default. Add this to a simple test program:
>
> #ifdef __STDC__
> printf("__STDC__\n");
> #else
> printf("NOT __STDC__\n");
> #endif
>
> Now if you go to before even the include parts and add "#undef 
> __STDC__" you'll get a compile error stating it needs an ISO 
> conforming C compiler to use glibc headers. Maybe there is a way to 
> get around this but probably it isn't worthwhile. Look at "man stdarg" 
> and you will see va_dcl isn't even part of variable arguments these 
> days. The sample Lori sent works because it is ANSI/ISO. You'll 
> probably have to convert to something newer than traditional C.
>
> D. Stimits, stimits AT comcast DOT net
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
>





More information about the LUG mailing list