Newsgroups: comp.sys.amiga.programmer
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!snorkelwacker.mit.edu!ira.uka.de!fauern!forwiss.uni-passau.de!r2d2!hessmann
From: hessmann@r2d2.fmi.uni-passau.de (Georg Hessmann)
Subject: Re: SAS C 5.10A has problems
Message-ID: <1991Jun27.121318.20585@forwiss.uni-passau.de>
Sender: usenet@forwiss.uni-passau.de (USENET News System)
Nntp-Posting-Host: r2d2.fmi.uni-passau.de
Organization: University of Passau, Germany
References: <mykes.3672@amiga0.SF-Bay.ORG> <1991Jun24.110845.19273@forwiss.uni-passau.de> <SIE.91Jun25133827@spinach.fulcrum.bt.co.uk>
Date: Thu, 27 Jun 91 12:13:18 GMT
Lines: 68

In article <SIE.91Jun25133827@spinach.fulcrum.bt.co.uk> sie@fulcrum.bt.co.uk (Sie) writes:
>
>>>>>> On 24 Jun 91 11:08:45 GMT, hessmann@unipas.fmi.uni-passau.de (Georg Hessmann) said:
>
> Georg> Nntp-Posting-Host: unipas.fmi.uni-passau.de
>
> Georg> In article <mykes.3672@amiga0.SF-Bay.ORG> mykes@amiga0.SF-Bay.ORG (Mike Schwartz) writes:
>>Problem #2: 	When compiling some sources, I get CXERR: 99, which is
>>NOT documented in the manual.  Nice messages, eh folks?  Real
>>descriptive :) The compiler does not complain about anything else in
>>the source file.  This error comes up during the Optimizing phase.
>
> Georg> I've got this message, too.  The reason was a varargs
> Georg> function.  If you use varargs functions with the 'va_list'
> Georg> type, try two things: First, declare the funktion as __stdargs
> Georg> and second, declare the 'va_list' variable as 'volatile'.
>
> Georg> E.g.: void __stdargs Message(char *fmt, ...)  { volatile
> Georg> va_list list: ...  }
>
>
>This can't be the problem, I use varargs all the time and have not had
>to do any of these things to make it compile ??

Try this:
----tst.c-----
#include <stdio.h>
#include <stdarg.h>

char maxline[300];

void Message(char *fmt,...);
void Warning(char *fmt,...);

void Message(char *fmt,...)               /* issue a message */
{
  va_list argptr;
  char *ptr;

  va_start(argptr, fmt);
  vsprintf(maxline, fmt, argptr);
  va_end(argptr);
  ptr = &(maxline[0]);

  printf("%s\n",ptr);

}

void Warning(char *fmt,...)             /* issue a warning */
{
  va_list argptr;
     
  va_start(argptr, fmt);
  Message(fmt, va_arg(argptr, char *), va_arg(argptr, char *));
  va_end(argptr);
}
 
void main(int argc, char *argv[])
{
  Warning("TEST %d %s",2,"aa");
}
--------
Compile it with: lc -O tst

	Georg.

-- 
  hessmann@unipas.fmi.uni-passau.de		hessmann@unipas.uucp
