2013-12-09 1 views
0

저는 리눅스에서 rpc 샘플 프로그램을 만들고 있습니다.rpc remote proceduer 컴파일 오류

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 

이 나는 ​​complie하는 데 사용되는 명령입니다 :

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); 
} 
내 원격 프로 시저를 컴파일 할 때이 오류를 얻을 수

내 코드에 어떤 문제가 있습니까?

+2

'printmessage_1' 함수의 인자 타입은'printmessage_1'이 아닌'printmessage_1_svc'의 선언과 일치합니다. – Barmar

+0

덕분에 문제가 해결되었습니다. 내 클라이언트 응용 프로그램에서 printmessage_1 대신 printmessage_1_svc를 사용해야합니다. – hamedkh

답변

0

printmessage_1 함수의 인수 형식이 printmessage_1이 아닌 printmessage_1_svc의 선언과 일치합니다. - Barmar