473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Prototype Declaration Error in RPC

Siddarth777
Hi,
I am writing a sample RPC program in C language using RPCGEN tool in my UBUNTU 12.04, when i have finished writing my client and server codes, and when i compile the complete project using a makefile i get error in my server code

i encounter the following errors

gcc -c -o svc_proc.o -g -Wall svc_proc.c
svc_proc.c: In function ‘greetings_1_svc’:
svc_proc.c:4:1: error: number of arguments doesn’t match prototype
helloworld.h:23:15: error: prototype declaration
svc_proc.c:8:2: warning: function returns address of local variable [enabled by default]
make: *** [svc_proc.o] Error 1


The codes of my server and helloworld.h files are

helloworld.h
Expand|Select|Wrap|Line Numbers
  1. /*
  2.  * Please do not edit this file.
  3.  * It was generated using rpcgen.
  4.  */
  5.  
  6. #ifndef _HELLOWORLD_H_RPCGEN
  7. #define _HELLOWORLD_H_RPCGEN
  8.  
  9. #include <rpc/rpc.h>
  10.  
  11.  
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15.  
  16.  
  17. #define HELLOWORLD 0x2fffffff
  18. #define HELLOWORLD_V1 1
  19.  
  20. #if defined(__STDC__) || defined(__cplusplus)
  21. #define greetings 1
  22. extern  int * greetings_1(void *, CLIENT *);
  23. extern  int * greetings_1_svc(void *, struct svc_req *);
  24. extern int helloworld_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
  25.  
  26. #else /* K&R C */
  27. #define greetings 1
  28. extern  int * greetings_1();
  29. extern  int * greetings_1_svc();
  30. extern int helloworld_1_freeresult ();
  31. #endif /* K&R C */
  32.  
  33. #ifdef __cplusplus
  34. }
  35. #endif
  36.  
  37. #endif /* !_HELLOWORLD_H_RPCGEN */
  38.  
svc_proc.c

Expand|Select|Wrap|Line Numbers
  1. #include"helloworld.h"
  2.  
  3. // This is the SERVER Code
  4.  
  5. int* greetings_1_svc()
  6. {
  7.     int i=0;
  8.     printf("This is your OWN RPC");
  9.     return &i;
  10. }
  11.  
please tell me where i am going wrong, thanks a lot in advance


Siddarth
Aug 12 '12 #1
1 5072
weaknessforcats
9,208 Expert Mod 8TB
You have declred your function in helloworld.h as:

Expand|Select|Wrap|Line Numbers
  1. extern  int * greetings_1_svc(void *, struct svc_req *);
The actual code is:

Expand|Select|Wrap|Line Numbers
  1. int* greetings_1_svc()
  2.  
etc...

The function and the prototype have to match. Clearly they do not.

BTW: greetings_1_svc is returning the addres of an int that is a local variable. Be aware that by the time you use the address that is returned, the variable will have been destroyed and your program will crash.
Aug 12 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: John Harrison | last post by:
I've seen cases before where it was intended to write a variable declaration but a function prototype was written instead (e.g. X x();) but I've come accross a new version of this (new to me at...
2
by: knutivar | last post by:
I download and grab a .NET solution from Vault and open it on my local computer. It works fine - I can compile it - no problems. But when I check it out and do a small changes in any classes. I...
7
by: iwdu15 | last post by:
i added a from called "Splash" to my project and am trying to get it to show up on a formload event...but it gives a buildtime error on the line below static Splash * frm = new Splash(); ...
0
by: Jon Paal | last post by:
why is there a declaration error on line 24 ? Compiler Error Message: BC30188: Declaration expected. Source Error: Line 22: Line 23: Dim vResource As New Collection Line 24: ...
6
by: Pierre Couderc | last post by:
What do I do wrong? class CTest { public: CTest(int uu); }; void ttt() {
1
by: michael | last post by:
Hi All, I have the following: #define MAX_SLEEP_TIME 1000 #include <unistd.h> void do_sleep(){ unsigned int random; while(TRUE){
7
by: Sheldon | last post by:
Hi, This is a simple mistake so Iam sure there is someone who can help with it: The the file.h: #define IBFLEN 50000 int IRET, ILEN, IUNIT1, IUNIT2, ILOOP, KERR;
1
by: Raman | last post by:
Hi All, I have two libs (libFirst.a and libSecond.a). Both libs contains a common function func(). Now I want to link an application "app" with these two libs as gcc -o app libFirst.a...
1
by: mthread | last post by:
Hi, I came across this prototype declaration virtual const char* what() const throw() I would like to know what is the purpose of last two words 'const throw()'
0
by: dougancil | last post by:
I have the following form: Imports System.Data.SqlClient Public Class Main Protected WithEvents DataGridView1 As DataGridView Dim instForm2 As New Exceptions Private Sub...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.