rpc远程程序编译错误

rpc远程程序编译错误,c,linux,rpc,C,Linux,Rpc,我正在linux上开发一个rpc示例程序。当我尝试编译远程过程时,出现以下错误: msg_proc.c:10:7: error: conflicting types for ‘printmessage_1’ In file included from msg_proc.c:8:0: msg.h:22:15: note: previous declaration of ‘printmessage_1’ was here 这是我用来编译的命令: cc msg_proc.c msg_svc.c -o

我正在linux上开发一个rpc示例程序。当我尝试编译远程过程时,出现以下错误:

msg_proc.c:10:7: error: conflicting types for ‘printmessage_1’
In file included from msg_proc.c:8:0:
msg.h:22:15: note: previous declaration of ‘printmessage_1’ was here
这是我用来编译的命令:

cc msg_proc.c msg_svc.c -o msg_server -lnsl
这些是我的头文件和过程文件:

/*msg.h
 *
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#ifndef _MSG_H_RPCGEN
#define _MSG_H_RPCGEN

#include <rpc/rpc.h>


#ifdef __cplusplus
extern "C" {
#endif


#define MESSAGEPROG 0x20000001
#define PRINTMESSAGEVERS 1

#if defined(__STDC__) || defined(__cplusplus)
#define PRINTMESSAGE 1
extern  int * printmessage_1(char **, CLIENT *);
extern  int * printmessage_1_svc(char **, struct svc_req *);
extern int messageprog_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define PRINTMESSAGE 1
extern  int * printmessage_1();
extern  int * printmessage_1_svc();
extern int messageprog_1_freeresult ();
#endif /* K&R C */

#ifdef __cplusplus
}
#endif

#endif /* !_MSG_H_RPCGEN */


/*
 * msg_proc.c: implementation of the
 * remote procedure "printmessage"
 */

#include <stdio.h>
#include <rpc/rpc.h>
#include "msg.h"

int * printmessage_1(char **msg, struct svc_req *req) {
    static int result; /* must be static! */
    FILE *f;

    f = fopen("/dev/console", "w");
    if (f == (FILE *) NULL) {
        result = 0;
        return (&result);
    }
    fprintf(f, "%s\n", *msg);
    fclose(f);
    result = 1;
    return (&result);
}
/*msg.h
*
*请不要编辑此文件。
*它是使用rpcgen生成的。
*/
#如果没有,请发送消息
#定义\u MSG\u H\u RPCGEN
#包括
#ifdef_uucplusplus
外部“C”{
#恩迪夫
#定义MESSAGEPROG 0x2000001
#定义PRINTMESSAGEVERS 1
#如果定义(uu STDC_uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
#定义打印消息1
外部int*打印消息_1(字符**,客户端*);
extern int*打印消息\u 1\u svc(字符**,结构svc\u请求*);
外部消息程序1自由结果(SVCXPRT*、xdrproc\u t、caddr\u t);
#else/*K&R C*/
#定义打印消息1
extern int*打印消息_1();
extern int*打印消息_1_svc();
extern int messageprog_1_freesult();
#endif/*K&R C*/
#ifdef_uucplusplus
}
#恩迪夫
#endif/*_MSG_H_RPCGEN*/
/*
*msg_proc.c:实施
*远程过程“打印消息”
*/
#包括
#包括
#包括“msg.h”
int*printmessage_1(字符**msg,结构svc_请求*req){
静态int结果;/*必须是静态的*/
文件*f;
f=fopen(“/dev/console”,“w”);
如果(f==(文件*)为空){
结果=0;
返回(&结果);
}
fprintf(f,“%s\n”,*msg);
fclose(f);
结果=1;
返回(&结果);
}

我的代码有什么问题?

您的
printmessage\u 1
函数中的参数类型与
printmessage\u 1\u svc
的声明相匹配,而不是
printmessage\u 1
Barmar

函数
printmessage\u 1
中的参数类型与
printmessage\u 1\u svc
的声明匹配,而不是
printmessage\u 1
。谢谢,我的问题解决了。我必须在客户端应用程序中使用printmessage_1_svc而不是printmessage_1。