c/1538: cannot compile with #include <sys/varargs.h>
garrett@damore.org
garrett@damore.org
Tue Jan 2 16:26:00 GMT 2001
>Number: 1538
>Category: c
>Synopsis: cannot compile with #include <sys/varargs.h>
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jan 02 16:26:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Garrett D'Amore
>Release: 2.95.2 19991024 (release)
>Organization:
>Environment:
Solaris 8, i386. (i386-pc-solaris2.8)
>Description:
Some device driver sources #include <sys/varargs.h>. This
makes it impossible to compile them with vanilla gcc.
The problem is that <sys/varargs.h> is pretty much the
same as <stdarg.h> for kernel sources on Solaris -- it
refers to compiler built-in features for variable length
arg-lists.
>How-To-Repeat:
Try compiling any driver source that uses the <sys/varargs.h>
interface (which is documented in the Sun DDK.) I've
included a file that compiles properly with Sun cc, but
fails with gcc. (Use cc -D_KERNEL -c).
>Fix:
The best solution is to have the gcc private include files
bundle a version of <sys/varargs.h> -- this should follow
the same semantics as <stdarg.h>. Actually, my solution
was to put a file that said "#include <stdarg.h>" into
this location:
/usr/local/lib/gcc-lib/i386-pc-solaris2.8/2.95.2/include/sys/varargs.h
Note that <sys/varargs.h> on Solaris follows the conventions
for ANSI varargs, not the old K&R rules, even though it is
named using <sys/varargs.h> instead of <sys/stdarg.h> (which
might have been more logical.)
When I made this change, I was able to compile driver sources
on Solaris 8 using gcc without difficulty.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="temp.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="temp.c"
I2luY2x1ZGUgPHN5cy9kZGkuaD4KI2luY2x1ZGUgPHN5cy9zdW5kZGkuaD4KI2luY2x1ZGUgPHN5
cy90eXBlcy5oPgojaW5jbHVkZSA8c3lzL3ZhcmFyZ3MuaD4KCi8qCiAqIFRoZXNlIGFyZSBjb2Rl
IHNuaXBwZXRz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7CgogICAgICAgIHZhX3N0YXJ0KGFwLCBmbXQp
OwogICAgICAgIGlmIChkZWJ1ZyAmIGxldmVsKSB7CiAgICAgICAgICAgICAgICB2ZXJyb3IoZGlw
LCBDRV9DT05ULCBmbXQsIGFwKTsKICAgICAgICB9CiAgICAgICAgdmFfZW5kKGFwKTsKfQo=
More information about the Gcc-bugs
mailing list