Subject: toolchain/18763: rpcgen expands macros that should be preserved
To: None <firstname.lastname@example.org>
From: None <email@example.com>
Date: 10/22/2002 13:38:17
>Synopsis: rpcgen expands macros that should be preserved
>Arrival-Date: Tue Oct 22 04:39:00 PDT 2002
>Originator: Andreas Johansson
>Release: NetBSD 1.6
Rockstorm Technology AB
System: NetBSD bmw 1.6 NetBSD 1.6 (GENERIC) #0: Sun Sep 8 19:43:40 UTC 2002 firstname.lastname@example.org:/autobuild/i386/OBJ/autobuild/src/sys/arch/i386/compile/GENERIC i386
rpcgen expands some macros built into cpp that should be passed on to the
output file. rpcgen doesn't really do any replacing, but it calls cpp in
order to evaluate #ifdef RPC_HDR statements and such, and it the process
some predefined macros gets expanded by cpp.
The macro I've been bitten by is __STDC__ which is replaced by '1', but I'm
sure this is not the only potential problem. Interrestingly, cpp -dM doesn't
even report that __STDC__ is defined. It can be undefined by cpp -U __STDC__,
but this always gives me a warning.
rpcgen -C -h rpcb_prot.x
Line 171 in rpcb_prot.x:
%extern bool_t xdr_rpcblist(XDR *, rpcblist**);
%#else /* K&R C */
will be replaced with:
extern bool_t xdr_rpcblist(XDR *, rpcblist**);
#else /* K&R C */
This doesn't really break anything as long as you compile with a standard
compiler, but it works only because __STDC__ was tested with #if. In
previous versions of NetBSD, it was tested with #ifdef, and this makes old
code uncompilable with a new toolchain (this is my real problem).
Maybe an option to cpp not to expand any macros (i.e. only respond to lines
that starts with '#'), and use this option in rpcgen?
The -undef option of cpp does not undefine __STDC__, so this option can't
solve the problem by itself. cpp -undef -U __STDC__ -U ... could be a fix,
but this leads to annoying warnings.