fullnitrous
fullnitrous

Reputation: 110

Using type defined in struct as type for function argument inside struct

typedef struct flag
  {
           int8_t (*valid)(Flag flag);
    const uint8_t requiresValue;
    const char*   name;
          uint8_t active;
          char*   value;

  } Flag;

How do i have the parameter for *valid be Flag inside the struct?

Upvotes: 0

Views: 40

Answers (1)

Dillon Davis
Dillon Davis

Reputation: 7750

The typedef you are looking for is as follows:

typedef struct flag
  {
           int8_t (*valid)(struct flag flag);
    const uint8_t requiresValue;
    const char*   name;
          uint8_t active;
          char*   value;

  } Flag;

I changed Flag to struct flag. Note the lowercase flag due to the first line typedef struct flag.

Upvotes: 1

Related Questions