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::_64BIT
command_options.h:
#ifndef __COMMANDOPTIONS_H
#define __COMMANDOPTIONS_H
struct CommandOptionCode
{
enum
{
HELPVERBOSE = 1,
PASSWORD = 2,
NOCOPYRIGHT = 3,
NOLOG = 4,
_64BIT = 5
};
};
#endif
When I run:
gperf -L C++ -t --output-file=perfecthash.hpp command_options.gperf
Only to get :
Empty input keyword is not allowed. To recognize an empty input keyword, your code should check for len == 0 before calling the gperf generated lookup function.
Version: GNU gperf 3.0.1 Why?
I discovered that gperf 2.7 did not care if there was a '%%' delimiter between the first section and the keywords. 3.0.1 strictly enforces this. So, in my case I had modify:
to be
Your case is different, I belive, in that the manual states that the first field of the struct must be called 'name':
-charlie