RPC 规范中结构内二维数组的定义不起作用
Definition of 2D array inside struct in RPC Specification not working
我正在尝试使用 RPC 实现 NFS。现在我的规范文件看起来像这样:(这是一个非常基本的版本:))
struct input
{
char command[20];
char arg[10][10];
int numargs;
};
struct lsresult
{
char arr[50][256];
};
program NFSPROG
{
version NFSVERSION
{
lsresult ls(input) = 1;
int cd(input) = 2;
int mkdir(input) = 3;
int mkfile(input) = 4;
} = 1;
} = 0x21111111;
当我尝试使用 rpcgen
编译此 Spec.x
时,出现如下错误:
char arg[10][10];
^^^^^^^^^^^^^^
Spec.x, line 4: expected ';'
这可能是什么原因?我不能在 RPC 规范 中的结构中声明一个二维数组吗? (当我尝试以这种方式声明变量时出现了同样的错误:int a,b,c
in the struct!)
在 rpcgen 的 termini 中,您需要一个字符串数组,而不是一个二维字符数组。首先,你必须 typedef 一个参数类型
typedef string arg<10>;
然后将这些参数组成一个数组:
struct input
{
string command<20>;
arg args[10];
int numargs;
};
与 lsresult 相似:
typedef string filename<50>;
struct lsresult
{
filename arr[256];
};
应该可行
我正在尝试使用 RPC 实现 NFS。现在我的规范文件看起来像这样:(这是一个非常基本的版本:))
struct input
{
char command[20];
char arg[10][10];
int numargs;
};
struct lsresult
{
char arr[50][256];
};
program NFSPROG
{
version NFSVERSION
{
lsresult ls(input) = 1;
int cd(input) = 2;
int mkdir(input) = 3;
int mkfile(input) = 4;
} = 1;
} = 0x21111111;
当我尝试使用 rpcgen
编译此 Spec.x
时,出现如下错误:
char arg[10][10];
^^^^^^^^^^^^^^
Spec.x, line 4: expected ';'
这可能是什么原因?我不能在 RPC 规范 中的结构中声明一个二维数组吗? (当我尝试以这种方式声明变量时出现了同样的错误:int a,b,c
in the struct!)
在 rpcgen 的 termini 中,您需要一个字符串数组,而不是一个二维字符数组。首先,你必须 typedef 一个参数类型
typedef string arg<10>;
然后将这些参数组成一个数组:
struct input
{
string command<20>;
arg args[10];
int numargs;
};
与 lsresult 相似:
typedef string filename<50>;
struct lsresult
{
filename arr[256];
};
应该可行