Lines starting with sign ‘%’ should be passed as is in output file,
but is such lines have some CPP macros, those macros are expanded as well:
Source (test.x):
#ifdef ONE
#warning "ONE is defined"
#else
#warning "NO ONE!!!!!1111"
#endif
%
% hello, ONE
%
Running rpcgen:
# rpcgen test.x -DONE
test.x:2:2: warning: #warning "ONE is defined" [-Wcpp]
test.x:2:2: warning: #warning "ONE is defined" [-Wcpp]
test.x:2:2: warning: #warning "ONE is defined" [-Wcpp]
test.x:2:2: warning: #warning "ONE is defined" [-Wcpp]
Result (test.h):
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#ifndef _TEST_H_RPCGEN
#define _TEST_H_RPCGEN
#include <rpc/rpc.h>
#ifdef __cplusplus
extern "C" {
#endif
hello, 1
#ifdef __cplusplus
}
#endif
#endif /* !_TEST_H_RPCGEN */
So “ONE” is replaced with “1”, but it is desirable leave it as is
(consider “#ifdef ONE” in resulting test.h)
It there any way to aviod it?
So, I have a workaroud with CPP wrapper:
somedir/cpp <- wrapped which undefines problematic macros. For example:
#!/bin/sh
exec /usr/bin/cpp -U_LP64
Run rpcgen as rpcgen -Y somedir