title: Remote procedure call: how to declare two versions of same program in a XDR file
body: <p>I am writing a program which makes a RPC to print a message that I send as a parameter to the remote function. The remote function is not supposed to return anything, however just out of curiosity I have designed the remote function to return an integer.</p>
  
  <p>Anyways, everything worked fine and I was able to print a message remotely. Now I am trying to create two versions of a program in XDR file (Just curious!!!) but its not working out for me.</p>
  
  <p>here is my new XDR file</p>
  
  <pre><code>anirudh@anirudh-Aspire-5920:~/Documents/C/DS/RPC$ cat spec.x 
  program MSGPROG{
  
      version PRINTMSGVERSION{
          int PRINTMSG(string) = 1;
      } = 1;
  
      version PRINTMSGVERSION{
          int PRINTMSG(string) = 1;
      } = 2;
  
  } = 0x2000001;
  </code></pre>
  
  <p>Here is the server code:</p>
  
  <pre><code>anirudh@anirudh-Aspire-5920:~/Documents/C/DS/RPC$ cat server.c 
  #include&lt;stdio.h&gt;
  #include "spec.h"
  
  int *printmsg_1_svc(char **msg,struct svc_req * sr){
      static int ret;
  
      printf("version = 1--%s\n",*msg);
      ret = 1;
      return &amp;ret;    
  }
  
  int *printmsg_2_svc(char **msg,struct svc_req * sr){
      static int ret;
  
      printf("version = 2--%s\n",*msg);
      ret = 1;
      return &amp;ret;    
  }
  </code></pre>
  
  <p>Here are the errors that I get at compile time:</p>
  
  <pre><code>anirudh@anirudh-Aspire-5920:~/Documents/C/DS/RPC$ rpcgen -C spec.x
  anirudh@anirudh-Aspire-5920:~/Documents/C/DS/RPC$ gcc server.c spec_svc.c -o ani_server -lnsl
  In file included from server.c:2:
  spec.h:32: warning: "PRINTMSGVERSION" redefined
  spec.h:18: note: this is the location of the previous definition
  In file included from spec_svc.c:6:
  spec.h:32: warning: "PRINTMSGVERSION" redefined
  spec.h:18: note: this is the location of the previous definition
  </code></pre>
  
  <p>So the error is coming because I am not able to figure out how to declare two versions of a program in XDR file. Thanks a lot for reading my post. Please help me out. Thanks in advance.</p>