Index | Thread | Search

From:
Lennart Jablonka <humm@ljabl.com>
Subject:
inconsistent va_list declaration with !defined(__GNUC__)
To:
tech@openbsd.org
Date:
Sun, 16 Jun 2024 21:00:32 +0000

Download raw body.

Thread
  • Lennart Jablonka:

    inconsistent va_list declaration with !defined(__GNUC__)

In 2020-07, sys/sys/stdarg.h lost its check for __GNUC__ (or 
__PCC__).  The type va_list is always the same as the type 
__builtin_va_list.

The sys/arch/*/include/_types.h files still check for __GNUC__: If 
defined, the type __va_list is the same as __builtin_va_list; 
otherwise, for example on amd64, it’s pointer to char.

The libc headers themselves use the type __va_list.  So if you 
use, say, vfprintf and you happen to use a compiler (cproc) that 
(1) supports __builtin_va_list, as required by libc, but also 
(2) does not pre-define __GNUC__, perhaps because it doesn’t 
implement the majority of the GNU C extensions, you’ll try to pass 
a __builtin_va_list as a pointer to char.  Which may very well 
result in compilation errors.  Which is what I’ve run into.

Surely there is no use for the non-__builtin_va_list __va_list in 
sys/arch/*/include/_types.h, is there?  Could the checks for 
__GNUC__ there simply be dropped?  At the least, I believe va_list 
and __va_list should be the same type, no matter what.