[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[help-gengetopt] gengetopt C example
From: |
Tong Sun |
Subject: |
[help-gengetopt] gengetopt C example |
Date: |
Tue, 22 Oct 2013 14:51:53 -0700 (PDT) |
Hi again Lorenzo,
I'm trying gengetopt with C this time, but the C example that come with my
Debian/Ubuntu package gave me some errors. The first one being:
In file included from cmdline2.c:26:0:
cmdline2.h:24:35: error: expected ',' or ';' before 'PACKAGE'
#define MY_CMDLINE_PARSER_PACKAGE PACKAGE
In details,
Here are the example files distributed from my Debian/Ubuntu package
/usr/share/doc/gengetopt/examples
/usr/share/doc/gengetopt/examples/cmdline2.c.gz
/usr/share/doc/gengetopt/examples/cmdline2.h.gz
/usr/share/doc/gengetopt/examples/sample1.ggo
/usr/share/doc/gengetopt/examples/main1.cc
/usr/share/doc/gengetopt/examples/main2.c
/usr/share/doc/gengetopt/examples/cmdline1.c.gz
/usr/share/doc/gengetopt/examples/README.example
/usr/share/doc/gengetopt/examples/test_manual_help_cmd.c.gz
/usr/share/doc/gengetopt/examples/test_manual_help.c
/usr/share/doc/gengetopt/examples/sample2.ggo
...
and my gengetopt:
$ apt-cache policy gengetopt
gengetopt:
Installed: 2.22.6-2
Candidate: 2.22.6-2
Version table:
*** 2.22.6-2 0
500 http://us.archive.ubuntu.com/ubuntu/ saucy/universe i386 Packages
100 /var/lib/dpkg/status
From /usr/share/doc/gengetopt/examples/README.example:
...
# commands to try the C example:
gengetopt --input=sample2.ggo --func-name=my_cmdline_parser
--file-name=cmdline2 --unamed-opts
gcc -o main2 main2.c cmdline2.c
./main2 -h
...
This is how I tried:
mkdir gengetopt; cd gengetopt
ln -s /usr/share/doc/gengetopt/examples/sample2.ggo
ln -s /usr/share/doc/gengetopt/examples/main2.c
gengetopt --input=sample2.ggo --func-name=my_cmdline_parser
--file-name=cmdline2 --unamed-opts
gcc -o main2 main2.c cmdline2.c
and here are all the errors that I get:
$ gcc -o main2 main2.c cmdline2.c
In file included from cmdline2.c:26:0:
cmdline2.h:24:35: error: expected ',' or ';' before 'PACKAGE'
#define MY_CMDLINE_PARSER_PACKAGE PACKAGE
^
cmdline2.c:30:51: note: in expansion of macro 'MY_CMDLINE_PARSER_PACKAGE'
const char *gengetopt_args_info_usage = "Usage: " MY_CMDLINE_PARSER_PACKAGE " [
^
cmdline2.c: In function 'my_cmdline_parser_print_version':
cmdline2.h:32:40: error: 'PACKAGE' undeclared (first use in this function)
#define MY_CMDLINE_PARSER_PACKAGE_NAME PACKAGE
^
cmdline2.c:165:14: note: in expansion of macro 'MY_CMDLINE_PARSER_PACKAGE_NAME'
(strlen(MY_CMDLINE_PARSER_PACKAGE_NAME) ? MY_CMDLINE_PARSER_PACKAGE_NAME :
^
cmdline2.h:32:40: note: each undeclared identifier is reported only once for
each function it appears in
#define MY_CMDLINE_PARSER_PACKAGE_NAME PACKAGE
^
cmdline2.c:165:14: note: in expansion of macro 'MY_CMDLINE_PARSER_PACKAGE_NAME'
(strlen(MY_CMDLINE_PARSER_PACKAGE_NAME) ? MY_CMDLINE_PARSER_PACKAGE_NAME :
^
cmdline2.h:38:35: error: 'VERSION' undeclared (first use in this function)
#define MY_CMDLINE_PARSER_VERSION VERSION
^
cmdline2.c:166:6: note: in expansion of macro 'MY_CMDLINE_PARSER_VERSION'
MY_CMDLINE_PARSER_VERSION);
^
cmdline2.c: In function 'my_cmdline_parser_dump':
cmdline2.h:24:35: error: 'PACKAGE' undeclared (first use in this function)
#define MY_CMDLINE_PARSER_PACKAGE PACKAGE
^
cmdline2.c:293:63: note: in expansion of macro 'MY_CMDLINE_PARSER_PACKAGE'
fprintf (stderr, "%s: cannot dump options to stream\n", MY_CMDLINE_PARSER
^
cmdline2.c: In function 'my_cmdline_parser_file_save':
cmdline2.h:24:35: error: 'PACKAGE' undeclared (first use in this function)
#define MY_CMDLINE_PARSER_PACKAGE PACKAGE
^
cmdline2.c:341:66: note: in expansion of macro 'MY_CMDLINE_PARSER_PACKAGE'
fprintf (stderr, "%s: cannot open file for writing: %s\n", MY_CMDLINE_PAR
^
cmdline2.c: In function 'my_cmdline_parser_internal':
cmdline2.h:24:35: error: 'PACKAGE' undeclared (first use in this function)
#define MY_CMDLINE_PARSER_PACKAGE PACKAGE
^
cmdline2.c:817:58: note: in expansion of macro 'MY_CMDLINE_PARSER_PACKAGE'
fprintf (stderr, "%s: option unknown: %c%s\n", MY_CMDLINE_PARSER_PACK
Any thoughts?
BTW, if you have a small working example, does it have a make file as well?
Thanks
- [help-gengetopt] gengetopt C example,
Tong Sun <=