Skip to content

Should anonymous structs be published? #142

@richard-ramos

Description

@richard-ramos

With this header, i noticed that anonymous structs and unions aren't being exported. Is this intentional?

Here's a small reproducible example

// test.h
typedef struct st_ptls_handshake_properties_t {
    union {
        struct {
            struct {
                const int *list;
                int count;
            } negotiated_protocols;
            
            int session_ticket;

            int *max_early_data_size;

            int early_data_acceptance;

            unsigned negotiate_before_key_exchange : 1;

            struct {
                int configs;

                int *retry_configs;
            } ech;
        } client;
        struct {
            struct {
                int base[10];
                int len;
            } selected_psk_binder;
           
            struct {
                const void *key;
                int additional_data;
            } cookie;

            unsigned enforce_retry : 1;
            unsigned retry_uses_cookie : 1;
        } server;
    };

} ptls_handshake_properties_t;
import futhark
from os import parentDir, `/`

importc:
    outputPath currentSourcePath.parentDir / "output.nim"
    path currentSourcePath.parentDir
    "test.h"

This generates the following code. Note how struct_st_ptls_handshake_properties_t_anon0_t_client_t is not exported. The same happens for struct_st_ptls_handshake_properties_t_anon0_t_client_t_ech_t and other structs

  struct_st_ptls_handshake_properties_t_anon0_t_client_t_ech_t {.pure, inheritable, bycopy.} = object  <----------------------------
    configs*: cint
    retry_configs*: ptr cint

...

struct_st_ptls_handshake_properties_t_anon0_t_client_t {.pure, inheritable,  bycopy.} = object  <----------------------------
    negotiated_protocols*: struct_st_ptls_handshake_properties_t_anon0_t_client_t_negotiated_protocols_t
    session_ticket*: cint
    max_early_data_size*: ptr cint
    early_data_acceptance*: cint
    negotiate_before_key_exchange* {.bitsize: 1'i64.}: cuint
    ech*: struct_st_ptls_handshake_properties_t_anon0_t_client_t_ech_t  <-------------

...

  struct_st_ptls_handshake_properties_t_anon0_t {.union, bycopy.} = object
    client*: struct_st_ptls_handshake_properties_t_anon0_t_client_t              <----------------
    server*: struct_st_ptls_handshake_properties_t_anon0_t_server_t

...

  struct_st_ptls_handshake_properties_t_520094121 {.pure, inheritable, bycopy.} = object
    anon0*: struct_st_ptls_handshake_properties_t_anon0_t

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions