Skip to content

Standardize struct + typedef usage.#1704

Open
antoinevg wants to merge 4 commits intogreatscottgadgets:mainfrom
antoinevg:antoinevg/consistent-structs
Open

Standardize struct + typedef usage.#1704
antoinevg wants to merge 4 commits intogreatscottgadgets:mainfrom
antoinevg:antoinevg/consistent-structs

Conversation

@antoinevg
Copy link
Copy Markdown
Member

@antoinevg antoinevg commented Mar 23, 2026

Depends on #1703


This PR standardizes struct definitions for HackRF firmware and resolves the ambiguity between declarations such as struct type_t and typedef struct type_t type_t

We prefer two formats:

1. Simple struct definitions:

struct definitions of the form:

struct fpga_driver_t;
typedef struct fpga_driver_t fpga_driver_t;

struct fpga_driver_t {
    ice40_spi_driver_t* bus;
    uint8_t regs[FPGA_NUM_REGS];
    uint8_t regs_dirty;
};

are refactored to:

typedef struct {
	ice40_spi_driver_t* bus;
	uint8_t regs[FPGA_NUM_REGS];
	uint8_t regs_dirty;
} fpga_driver_t;

2. Self-referential struct definitions:

Self-referential definitions of the form:

struct max5864_driver_t;
typedef struct max5864_driver_t max5864_driver_t;

struct max5864_driver_t {
    spi_bus_t* const bus;
    void (*target_init)(max5864_driver_t* const drv);
};

are refactored to:

typedef struct _max5864_driver_t {
    spi_bus_t* const bus;
    void (*target_init)(struct _max5864_driver_t* const drv);
} max5864_driver_t;

@antoinevg antoinevg force-pushed the antoinevg/consistent-structs branch from 65b74ca to ac4edd5 Compare March 24, 2026 07:43
@mossmann mossmann self-requested a review March 24, 2026 14:08
@antoinevg antoinevg force-pushed the antoinevg/consistent-structs branch 6 times, most recently from d97be1f to 943a600 Compare March 31, 2026 09:01
This was referenced Apr 2, 2026
@antoinevg antoinevg force-pushed the antoinevg/consistent-structs branch from 943a600 to 046b6a7 Compare April 2, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants