Groctel
Groctel

Reputation: 140

rpcgen only one argument is allowed error

I'm writing a simple client-server calculator with rpcgen and am having a compilation error. Here's the .x file (calculadora.x):

union resultado_calculo switch (int err)
{
    case 0:
        int resultado;
    default:
        void;
};

program CALCULADORA_PROG
{
    version CALCULADORA_VER
    {
        resultado_calculo Suma     (int, int) = 1;
        resultado_calculo Resta    (int, int) = 2;
        resultado_calculo Producto (int, int) = 3;
        resultado_calculo Cociente (int, int) = 4;
    } = 1;
} = 20000001;

Running rpcgen -NCa calculadora.x creates the following files:

total 40K
drwxr-xr-x 2 groctel groctel 4.0K Mar 23 16:40 .
drwxr-xr-x 3 groctel groctel 4.0K Mar 23 16:10 ..
-rw-r--r-- 1 groctel groctel 1.3K Mar 23 16:27 calculadora_client.c
-rw-r--r-- 1 groctel groctel 1.9K Mar 23 16:22 calculadora_clnt.c
-rw-r--r-- 1 groctel groctel 1.1K Mar 23 15:56 calculadora_server.c
-rw-r--r-- 1 groctel groctel 3.5K Mar 23 16:22 calculadora_svc.c
-rw-r--r-- 1 groctel groctel 1.2K Mar 23 16:23 Makefile.calculadora
-rw-r--r-- 1 groctel groctel 2.7K Mar 23 16:22 calculadora.h
-rw-r--r-- 1 groctel groctel  348 Mar 23 16:22 calculadora.x

Now, I've filled the client and server's templates and run the program several times. I have to compile with make CFLAGS+="-I/usr/include/tirpc -ltirpc" -f Makefile.calculadora to include my system's rpc library but no real problems there. I've also run the program a few times and all the operations run well (./calculadora 3 + 2 returns 5 for example).

However, I went to make the program again today and I'm getting the following output:

➜ make CFLAGS+="-I/usr/include/tirpc -ltirpc" -f Makefile.calculadora 
rpcgen  calculadora.x
  resultado_calculo Suma (int, int) = 1;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
calculadora.x, line 13: only one argument is allowed
make: *** [Makefile.calculadora:32: calculadora_xdr.c] Error 1

I don't understand why the error is appearing now and not before, since the program was running perfectly just yesterday. Here's the Suma function that I'm compiling:

resultado_calculo *
suma_1_svc(int arg1, int arg2,  struct svc_req *rqstp)
{
    static resultado_calculo  result;

    xdr_free(xdr_resultado_calculo, &result);
    result.resultado_calculo_u.resultado = arg1 + arg2;

    return &result;
}

The other functions are the exact same with different operators (-, * and /). What am I doing wrong?

Upvotes: 0

Views: 511

Answers (1)

Barmar
Barmar

Reputation: 782130

You need to use the -N option to allow multiple arguments. From the documentation:

-N
Use the newstyle of rpcgen. This allows procedures to have multiple arguments. It also uses the style of parameter passing that closely resembles C. So, when passing an argument to a remote procedure you do not have to pass a pointer to the argument but the argument itself. This behaviour is different from the oldstyle of rpcgen generated code. The newstyle is not the default case because of backward compatibility.

Prior to this feature, the way you passed multiple arguments was by packing them into a structure and passing a pointer to the structure.

Upvotes: 2

Related Questions