Subject: toolchain/18763: rpcgen expands macros that should be preserved
To: None <gnats-bugs@gnats.netbsd.org>
From: None <ajo@rockstorm.se>
List: netbsd-bugs
Date: 10/22/2002 13:38:17
>Number: 18763
>Category: toolchain
>Synopsis: rpcgen expands macros that should be preserved
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: toolchain-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Oct 22 04:39:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Andreas Johansson
>Release: NetBSD 1.6
>Organization:
Rockstorm Technology AB
>Environment:
System: NetBSD bmw 1.6 NetBSD 1.6 (GENERIC) #0: Sun Sep 8 19:43:40 UTC 2002 autobuild@tgm.daemon.org:/autobuild/i386/OBJ/autobuild/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
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.
>How-To-Repeat:
cd src/include/rpc
rpcgen -C -h rpcb_prot.x
Line 171 in rpcb_prot.x:
%#if __STDC__
%extern bool_t xdr_rpcblist(XDR *, rpcblist**);
%#else /* K&R C */
%bool_t xdr_rpcblist();
%#endif
will be replaced with:
#if 1
extern bool_t xdr_rpcblist(XDR *, rpcblist**);
#else /* K&R C */
bool_t xdr_rpcblist();
#endif
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).
>Fix:
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.
>Release-Note:
>Audit-Trail:
>Unformatted: