我正在尝试使用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;
当我尝试使用Spec.x
编译此rpcgen
时,我收到如下错误:
char arg[10][10];
^^^^^^^^^^^^^^
Spec.x, line 4: expected ';'
这可能是什么原因?我不能在RPC规范中的结构中声明一个2D数组吗? (当我尝试以这种方式声明变量时出现相同的错误:结构中的int a,b,c
!)
在rpcgen的末尾,你需要一个字符串数组,而不是一个2d的字符数组。首先,您必须键入一个参数类型
typedef string arg<10>;
然后创建一个这些参数的数组:
struct input
{
string command<20>;
arg args[10];
int numargs;
};
类似于lsresult:
typedef string filename<50>;
struct lsresult
{
filename arr[256];
};
这应该工作