[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Info-gengetopt] the default example canot be compiled with gengetop

From: Grégoire Scano
Subject: Re: [Info-gengetopt] the default example canot be compiled with gengetopt-2.23 version
Date: Mon, 29 Jun 2020 21:20:51 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

Hi Hossein,

On 6/26/20 9:59 AM, Hossein Aghakhani wrote:
> I am new to gengetopt, however, it looks a very useful tool that I was
> looking for it for a long time. > I am trying to learn how does it work and 
> for doing that, I am trying to
> redo the provided example in the original webpage
> at: I have
> successfully installed the latest version ( gengetopt-2.23), but when I
> want to compile as it says in the example I am getting the
> following error:
> In function ‘int main(int, char**)’:
> error: ‘struct gengetopt_args_info’ has no member named
> ‘inputs_num’
>    33 |   for ( unsigned i = 0 ; i < args_info.inputs_num ; ++i )
>       |                                        ^~~~~~~~~~
> error: ‘struct gengetopt_args_info’ has no member named
> ‘inputs’
>    34 |     cout << "file: " << args_info.inputs[i] << endl ;
> I checked the header file and it seems that the error is legitimate and
> that member has not been created for the gengetopt_args_info structure.
> I wonder if you know how can I fix this issue or if you know that I am
> missing a part. Thank you in advance for your help.

Although I cannot reproduce your problem for the 2.23 tarball, I think
the documentation can be misleading because it does not emphasize the
use of the '--unnamed-opts' option. The 'inputs_num' and 'inputs'
members are generated when the '--unnamed-opts' option is given, so I
think you somehow executed gengetopt without it.

Did you run the second command line as is (appropriate way)
'gengetopt < sample1.ggo --file-name=cmdline1 --unnamed-opts'
or did you run the first one
'gengetopt < sample1.ggo'
and then renamed the generated files from 'cmdline.{c,h}' to
'cmdline1.{c,h}' (not using the '--unnamed-opts' option) ?

The complete workflow from the documentation should be:
# gengetopt < sample1.ggo --file-name=cmdline1 --unnamed-opts
# gcc -c cmdline1.c
# g++ -c
# g++ -o sample1 cmdline1.o main1.o

Let me know if you did something similar,
Best regards,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]