Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typedef and anonymous structs #8

Closed
trikko opened this issue Mar 20, 2013 · 5 comments
Closed

typedef and anonymous structs #8

trikko opened this issue Mar 20, 2013 · 5 comments

Comments

@trikko
Copy link

trikko commented Mar 20, 2013

Something like this:

typedef struct { ... } struct_name;

is a common pattern in c. It's just a way to rename an anonymous struct.

dstep split this in two different declaration

struct anonymous
{
}

and

alias anonymous struct_name;

Original anonymous struct will be never used and can't be called from C code, so I think this two declaration can be merged in a single named struct.

@w0rp
Copy link

w0rp commented Mar 30, 2015

I saw this myself when I was converting a header. I ended up having to pick the output apart myself and set the structs in the right way.

@jacob-carlborg
Copy link
Owner

I do know it's not optimal, but it should still work?

@jacob-carlborg
Copy link
Owner

Another case where the struct has a name but only appears in a typedef:

typedef struct rd_kafka_metadata {
        int         broker_cnt;     /* Number of brokers in 'brokers' */
        struct rd_kafka_metadata_broker *brokers;  /* Brokers */

        int         topic_cnt;      /* Number of topics in 'topics' */
        struct rd_kafka_metadata_topic *topics;    /* Topics */

        int32_t     orig_broker_id; /* Broker originating this metadata */
        char       *orig_broker_name; /* Name of originating broker */
} rd_kafka_metadata_t;


rd_kafka_metadata (rd_kafka_t *rk, int all_topics,
                   rd_kafka_topic_t *only_rkt,
                   const struct rd_kafka_metadata **metadatap,
                   int timeout_ms);

@ciechowoj
Copy link
Contributor

Isn't is already fixed?

@w0rp
Copy link

w0rp commented Jul 29, 2016

I don't know myself. Try the Pebble headers. That's what I was translating at the time.

ciechowoj added a commit to ciechowoj/dstep that referenced this issue Aug 30, 2016
ciechowoj added a commit to ciechowoj/dstep that referenced this issue Aug 31, 2016
ciechowoj added a commit to ciechowoj/dstep that referenced this issue Aug 31, 2016
ciechowoj added a commit to ciechowoj/dstep that referenced this issue Aug 31, 2016
ciechowoj added a commit to ciechowoj/dstep that referenced this issue Aug 31, 2016
ciechowoj added a commit to ciechowoj/dstep that referenced this issue Aug 31, 2016
ciechowoj added a commit to ciechowoj/dstep that referenced this issue Sep 4, 2016
ciechowoj added a commit to ciechowoj/dstep that referenced this issue Sep 4, 2016
ciechowoj added a commit to ciechowoj/dstep that referenced this issue Sep 8, 2016
ciechowoj added a commit to ciechowoj/dstep that referenced this issue Sep 8, 2016
jacob-carlborg added a commit that referenced this issue Sep 25, 2016
Fix #8: Typedef and anonymous structs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants