以符号 '%' 开头的行应该在输出文件中按原样传递,但是这些行是否有一些 CPP 宏,这些宏也会被扩展:
来源(test.x):
#ifdef ONE
#warning "ONE is defined"
#else
#warning "NO ONE!!!!!1111"
#endif
%
% hello, ONE
%
运行 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]
结果(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 */
所以“ONE”被“1”替换,但最好保持原样(在结果 test.h 中考虑“#ifdef ONE”)
有什么办法可以避免吗?