2013-12-09 4 views
0

Я работаю над программой rpc sample на linux. Когда я пытаюсь скомпилировать свою удаленную процедуру, я получаю эту ошибку:rpc remote procedureuer compile error

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); 
} 

Что случилось с моим кодом?

+2

Типы аргументов в вашей функции 'printmessage_1' соответствуют объявлению' printmessage_1_svc', а не 'printmessage_1'. – Barmar

+0

спасибо, что была проблема решена. Я должен использовать printmessage_1_svc вместо printmessage_1 в своем клиентском приложении. – hamedkh

ответ

0

Типы аргументов в вашей функции printmessage_1 соответствуют объявлению printmessage_1_svc, а не printmessage_1. - Barmar