Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • GnuTLS GnuTLS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 252
    • Issues 252
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 18
    • Merge requests 18
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gnutlsgnutls
  • GnuTLSGnuTLS
  • Issues
  • #1337
Closed
Open
Created Mar 15, 2022 by Gisle Vanem@gvanem

MSVC problem with gen-getopt.py

Two of generated .h-files in ./src does not work with MSVC; certtool-options.h and psktool-options.h:

psktool-options.h(55): error C2016: C requires that a struct or union have at least one member

I.e. for this code:

  /* Option enablement status */
  struct
  {

  } enabled;

A fix for me was to modify gen-getopt.py to insert some int dummy; statements for such empty lists:

--- a/src/gen-getopt.py 2022-03-13 16:34:15
+++ b/src/gen-getopt.py 2022-03-15 14:39:36
@@ -501,7 +501,7 @@
     global_name = f'{mangle(prog_name)}Options'
     list_struct_name = f'{mangle(prog_name)}_list'

-    for option in options:
+    for i, option in enumerate(options):
         long_opt = option['long-option']
         arg_type = option.get('arg-type')
         lower_opt = mangle(long_opt)
@@ -528,6 +528,8 @@
                     f'{global_name}.list.{lower_opt}.args\n'
                 ))
             else:
+                if i == 0:
+                   struct_members_list.write (f'{INDENT*2}int dummy;\n')
                 struct_members_arg.write(
                     f'{INDENT*2}const char *{lower_opt};\n'
                 )
@@ -544,6 +546,8 @@
                 f'#define ENABLED_OPT_{upper_opt} '
                 f'{global_name}.enabled.{lower_opt}\n'
             ))
+        elif i == 0:
+            struct_members_enabled.write (f'{INDENT*2}int dummy;\n')

         have_opts.write((
             f'#define HAVE_OPT_{upper_opt} '

But I'm not sure how a proper fix would look like.

Edited Mar 15, 2022 by Gisle Vanem
Assignee
Assign to
Time tracking