bugGNU Gengetopt - Bugs: bug #47087, struct option from generated ggo.c...

 
 

bug #47087: struct option from generated ggo.c conflict with getopt.h from mac os sdk

Submitter:  João Santinha <jsantinha>
Submitted:  Mon 08 Feb 2016 09:09:05 AM UTC
   
 
Category:  None Severity:  2 - Minor
Item Group:  None Status:  Need Info
Privacy:  Public Assigned to:  gscano
Originator Name:  Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 19 Nov 2020 03:46:05 AM UTC, comment #1: 

I think you may have an inclusion problem.

Did you run gengetopt with --include-getopt then compiled the generated source file with -DHAVE_CONFIG_H and have included <getopt.h> in config.h or in a header included in config.h?

I have the same type of error on GNU/Linux when I proceed like this.

Grégoire Scano <gscano>
Group Member
Mon 08 Feb 2016 09:09:05 AM UTC, original submission:  

I have a project in which I am using gengetopt. In this project, I have two different settings (research and end user). The first one, for research purposes to which I create an executable that can be executed via command line  and the second one, in which I create a library with the same functionality that will be added to a mac os x application to be given to an end user.

When using the library, to access the args_info structure with the default values , I need to add/include the generated ggo.c and ggo.h files to my mac os application project. It happens that the definition of 'struct option’ in the generated ggo.c file is conflicting with the mac os x sdk since the sdk has the getopt.h, that also defines 'struct option’.

Bellow you can see the errors:
test_ggo.c:504:8: Redefinition of 'option'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/getopt.h:54:8: Previous definition is here
test_ggo.c:789:40: Definition of 'struct option' must be imported from module 'Darwin.getopt' before it is required
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/getopt.h:54:8: Previous definition is here

Do you know any solution to this issue?
I am not sure if this would solve it but I notice that the ‘struct getopt_data’ (present in the mac os sdk getopt.h) was changed to ’struct custom_getopt_data’ in the generated ggo.c file. Would it also be possible to apply (without impact) the "custom_" prefix to the ‘struct option” so it doesn't conflict with the mac os x sdk?

João Santinha <jsantinha>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gscano (Posted a comment)
  • -email is unavailable- added by jsantinha (Submitted the item)
  • -email is unavailable- added by jsantinha
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-11-19 gscano Severity3 - Normal 2 - Minor
        StatusNone Need Info
        Assigned toNone gscano
    2016-02-08 jsantinha Carbon-Copy- Added jsantinha

    Back to the top

    Powered by Savane 3.13-5884.
    Corresponding source code