🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #52379

stdarg on sun sparc and gcc 2.1 question

#52379
From: Gerben Wierda
Date: Thu, 22 Oct 1992 13:03
133 lines
4567 bytes
zendutil.c:689: `__builtin_va_alist' undeclared (first use this function)
zendutil.c:689: warning: value computed is not used
zendutil.c:687: warning: `argpt' may be used uninitialized in this function

These are the error message I get on the following code:

extern void
#if _ANSI_DEFUN_
zlog( const char *format, ...)
#else
zlog( format, va_alist)
char *format;
va_dcl
#endif
{
    va_list argpt;

    va_begin( argpt, format);
    vzlog( format, argpt);
    va_end( argpt);
}

Where _ANSI_DEFUN_ is true when __STDC__ is true. 

I suspect a subtle mismatch in the defnitions of portansi.h (local) and
va-sparc.h but I cannot find out what is happening.

The portansi.h file says:

/*++*
 * DEFVARG, va_begin, ___	<stdarg.h> vs. <varargs.h>
 *
 * Some compilers _require_ ANSI-style definitions, as well as ANSI-style
 * prototypes, for functions with variable number of arguments.  Hence the
 * existence of DEFVARG.  It takes as arguments the function's name,
 * its ANSI-style argument list, and its oldstyle argument list including
 * a trailing `va_alist' in the parameter list but without the corresponding
 * `va_dcl' in the parameter declarations--that is added implicitly if 
 * necessary.
 *
 * The macro `va_begin' is defined to replace the `va_start' macro, that is
 * defined with a single parameter in <varargs.h> and with two parameters
 * in <varargs.h>.
 *
 * The macro `___' (three underscores) is intended for use in prototypes
 * and ANSI-style definitions of varargs functions.  You should use this
 * instead of `, ...' in prototypes for maximum portability.
 * (some early near-ANSI compilers do not yet support the `ellipses' syntax
 *  and expect just a trailing comma instead; and some even may support the
 *  (early?) C++ syntax (`...' _without_ a comma) -- this is described by
 *  the value of _ANSI_CXX_ELLIPSES_.  However these do not seem 
 *  too abundant, so you may decide not to care about this.)
 *
 * For example, consider a function with the following ANSI prototype:
 *
 *	int printf(const char *format, ...);
 *
 * In our `portable ANSI C' would be defined as:
 *
 *	#include "portansi.h"
 *
 *	#if _STDARG_
 *	#   include <stdarg.h>
 *	#else
 *	#   include <varargs.h>
 *	#endif
 *
 *	int printf __(( const char *_(format) ___ ));	// prototype
 *
 *	int
 *	DEFVARG( printf, (const char *format ___),	// definition
 *			 (format, va_alist) const char *format; ) 
 *	{
 *		va_list ap;
 *
 *		va_begin(ap, format);
 *		etc...
 *	}
 *
 * Note that the programmer should include the correct header, according
 * to the value of _STDARG_.  Also note that for maximum portability the 
 * last fixed parameter of a stdarg function should not be declared `register' 
 * since many implementations of va_start() do somehow take its address.
 *
 * (If you don't like this style, you can of course still use a manifest
 *  preprocessor conditional, for example:
 *
 *	int
 *	#if (_STDARG_ && _ANSI_DEFUN_)
 *	printf(const char *format ___)
 *	#else
 *	printf(format, va_alist)
 *	const char *format;
 *	va_dcl
 *	#endif
 *	{ etc... }
 *
 *  whatever ticks you off:-)
 *--*/

#if _STDARG_
#   define	va_begin(ap, last)	va_start(ap, last)
#   if _ANSI_DEFUN_
#	define	DEFVARG(fun, proto, traditional)	fun proto
#   else
#	define	DEFVARG(fun, proto, traditional)	fun traditional
#	define	va_dcl
#   endif
#else
#   define	va_begin(ap, last)	va_start(ap)
#   define	DEFVARG(fun, proto, traditional)	fun traditional va_dcl
#endif

#if _ANSI_PROTO_
#   ifndef ___
#	if _ANSI_ELLIPSES_
#	    define ___	, ...
#	else
#	    if _ANSI_CXX_ELLIPSES_
#		define ___
#	    else
#		define ___	,
#	    endif
#	endif
#   endif
#endif


-- 
wierda@ltb.bso.nl (Gerben Wierda)     ||    #include <std/disclaimer.h>. Support
NeXTmail: gerben@rna.indiv.nluug.nl   ||    the League for Programming Freedom!
    "If you don't know where you are going, any road will take you there."
    (From the Talmud(?), rephrased in) Lewis Carroll, "Alice in Wonderland".
Technical Details
Message-ID: <2116@ltb.ltb.bso.nl>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!ltb!wierda

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,a1c006fbbcbc0f13,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1992-10-22 02:31:34 PST
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!ltb!wierda
From: wierda@ltb.ltb.bso.nl (Gerben Wierda)
Newsgroups: gnu.gcc.help
Subject: stdarg on sun sparc and gcc 2.1 question
Message-ID: <2116@ltb.ltb.bso.nl>
Date: 22 Oct 92 13:03:15 GMT
Organization: BSO/LT, Baarn, The Netherlands
Lines: 133