bugGNU Gengetopt - Bugs: bug #40244, please #include <unistd.h>...

 
 

bug #40244: please #include <unistd.h> in generated code

Submitter:  Török Edwin <edwintorok>
Submitted:  Fri 11 Oct 2013 04:31:08 PM UTC
   
 
Category:  None Severity:  4 - Important
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  gscano
Originator Name:  Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 19 Nov 2020 04:23:35 AM UTC, comment #1: 

Include <unistd.h> when <getopt.h> is included for conformance with the man-page. Do not include it when --include-getopt is specified.

Thanks.

Grégoire Scano <gscano>
Group Member
Fri 11 Oct 2013 04:31:08 PM UTC, original submission:  

According to getopt(3) the variables optarg, optind, etc. are declared in <unistd.h>, so it should be included before using it.

For example when trying to build gengetopt generated code with the LSB SDK I get errors like:
cmdline.c:483:3: error: 'optarg' undeclared (first use in this function)
cmdline.c:483:3: note: each undeclared identifier is reported only once for each function it appears in
cmdline.c:484:3: error: 'optind' undeclared (first use in this function)
cmdline.c:485:3: error: 'opterr' undeclared (first use in this function)
cmdline.c:486:3: error: 'optopt' undeclared (first use in this function)

Adding #include <unistd.h> to config.h works around the problem in an ugly way, but it would be better if gengetopt's generated code had that include already. (or if I could add that #include to .ggo to instruct gengetopt to include it for me).

Thanks.

Török Edwin <edwintorok>

 

(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 edwintorok (Submitted the item)
  • -email is unavailable- added by edwintorok
  •  

    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 4 - Important
        StatusNone Fixed
        Assigned toNone gscano
    2013-10-11 edwintorok Carbon-Copy- Added edwintorok

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code