rpcgen can also produce output that is compatible with ANSI C. This feature is selected with the -C compile flag and is most often used with the -N flag, described in Compile-Time C-style Mode.
The add.x example of the server template is generated by the rpcgen -N -C -Ss -o add_server_template.c add.x command:
Note that on the C++ 3.0 server, remote procedure names require an _svc suffix. In the following example, the add.x template and the -C compile flag produce the client side add_1 and the server stub add_1_svc.
/* * This is a template. Use it to * develop your own functions. */ #include <c_varieties.h> #include "add.h" int * add_1_svc(int arg1, int arg2, struct svc_req *rqstp) { static int result; /* * insert server code here */ return(&result); }
This output conforms to the syntax requirements and structure of ANSI C. The header files that are generated when this option is invoked can be used with ANSI C or with C++.