command_options.gperf:
%{
#include "command_options.h"
typedef struct CommandOptionCode CommandOptionCode;
%}
struct CommandOption
{
const char *Option;
int OptionCode;
};
%%
+helpverbose, CommandOptionCode::HELPVERBOSE
+password, CommandOptionCode::PASSWORD
+nocopyright, CommandOptionCode::NOCOPYRIGHT
+nolog, CommandOptionCode::NOLOG
+_64bit, CommandOptionCode::_64BITcommand_options.h:
#ifndef __COMMANDOPTIONS_H
#define __COMMANDOPTIONS_H
struct CommandOptionCode
{
enum
{
HELPVERBOSE = 1,
PASSWORD = 2,
NOCOPYRIGHT = 3,
NOLOG = 4,
_64BIT = 5
};
};
#endif当我跑步时:
gperf -L C++ -t --output-file=perfecthash.hpp command_options.gperf只得到:
不允许
空输入关键字。要识别空输入关键字,代码应该在调用gperf生成的查找函数之前检查len == 0。
版本: GNU gperf 3.0.1为什么?
发布于 2011-04-19 20:45:50
我发现gperf 2.7并不关心在第一节和关键字之间是否有‘%’分隔符。3.0.1严格执行这一规定。所以,在我的例子中,我修改了:
%{
#include <string.h>
%}
scan成为
%{
#include <string.h>
%}
%%
scan我相信,您的情况是不同的,因为手册规定结构的第一个字段必须称为'name':
"This first field must be called `name', although it is possible to modify its name with the `-K' option (or, equivalently, the `%define slot-name' declaration) described below."-charlie
发布于 2011-10-26 09:28:15
我发现gperf不喜欢关键字部分中的空行。它将空行视为空字符串,因为它不是注释,并抱怨它是‘空的’和有len=0的。因为我有一个习惯,总是用空行结束一个文件(有些汇编程序和编译器不想要它),这总是一个问题!
发布于 2013-08-14 08:09:55
除了Richard提到的空行问题外,gperf还不喜欢某些标记之前的空格。(我剪切并粘贴了一个简单的gperf示例,在用户的输入中寻找“粗鲁”的单词。)样品的名字很粗鲁-1.1.gperf。)该示例有一些缩进,从而触发了同样的错误。)
https://stackoverflow.com/questions/5321881
复制相似问题