首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >rpc远程过程编译错误

rpc远程过程编译错误
EN

Stack Overflow用户
提问于 2013-12-09 23:39:33
回答 1查看 515关注 0票数 0

我正在开发一个linux上的rpc示例程序。当我试图编译我的远程过程时,我得到了这个错误:

代码语言:javascript
复制
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

这是我用来编译的命令:

代码语言:javascript
复制
cc msg_proc.c msg_svc.c -o msg_server -lnsl

下面是我的头文件和过程文件:

代码语言:javascript
复制
/*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);
}

我的代码出了什么问题?

EN

回答 1

Stack Overflow用户

发布于 2016-10-13 15:45:31

printmessage_1函数中的参数类型与printmessage_1_svc的声明匹配,而不是与printmessage_1的声明匹配。-- Barmar

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20474532

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档