Solved

how to use rpcgen

Posted on 2008-10-16
7
2,156 Views
Last Modified: 2012-08-14
Hi,

I am trying to follow a tutorial on using rpcgen. I am new to the C language so I'm just trying to follow exactly as the tutorial says. Please see http://www.cs.cf.ac.uk/Dave/C/node34.html

When I get up to "cc msg_proc.c msg_svc.c -o msg_server -lnsl " i get the following error:

msg_proc.c:11: error: conflicting types for printmessage_1
msg.h:22: error: previous declaration of printmessage_1 was here

Can anybody tell me what I might be doing wrong? I have copied the code exactly from the website.

If its relevant I am using Ubuntu 8.04

Thanks,
Michael
0
Comment
Question by:mstrelan
  • 4
  • 2
7 Comments
 
LVL 45

Expert Comment

by:sunnycoder
Comment Utility
Message simply means that you have two declaration of function printmessage_1 and both have different types.
If you check line number 11 in file msg_proc.c and line number 22 in msg.h you would see the two types. You need to resolve the error by using either one of those.

I have not looked through the entire page but I could not locate a msg.h on a quick scan. If you wrote that file, then  you might want to change the declaration in the msg.h file to match the definition in the .c file.
0
 
LVL 53

Expert Comment

by:Infinity08
Comment Utility
In msg_proc.c, the function's signature is this :

        int * printmessage_1(char **msg, struct svc_req *req)

Check the msg.h file (on the indicated line 22) to see if the function's signature is exactly the same there.
0
 
LVL 53

Expert Comment

by:Infinity08
Comment Utility
>> but I could not locate a msg.h on a quick scan.

msg.h is generated by rpcgen.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 53

Expert Comment

by:Infinity08
Comment Utility
If the above doesn't solve your problem, then you need to check for a typo you might have made in msg_proc.c (in the function's signature more specifically), and you should post your msg.x file.
0
 
LVL 10

Author Comment

by:mstrelan
Comment Utility
thanks for your quick responses... msg.h is auto generated so I probably shouldn't be touching it. here is what I've got...
/* msg.h line 22: */

extern  int * printmessage_1(char **, CLIENT *);
 
 

/* msg_proc.c line 11: */

int * printmessage_1(char **msg, struct svc_req *req)
 

{

Open in new window

0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 500 total points
Comment Utility
Depending on the platform, you might have to change the function name to printmessage_1_svc in the msg_proc.c file, so :

        int * printmessage_1_svc(char **msg, struct svc_req *req)
0
 
LVL 45

Expert Comment

by:sunnycoder
Comment Utility
what is the definition for CLIENT ? Can it be mapped to struct svc_req? If no then renaming the function in .c is the only option as I08 already said. Also if you need the declaration of the function in msg_proc.c file in some other source file, then you will have to include it using another manually generated .h file.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now