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

Provide a macro to find a particular struct in a struct chain #278

Open
kainino0x opened this issue Mar 6, 2024 · 0 comments
Open

Provide a macro to find a particular struct in a struct chain #278

kainino0x opened this issue Mar 6, 2024 · 0 comments
Labels
non-breaking Does not require a breaking change (that would block V1.0)

Comments

@kainino0x
Copy link
Collaborator

Related to #272 where we discuss the few cases where, depending on the outcome of that issue, we may return a chained struct to the application (rather than the application constructing one and passing it to the implementation).

Providing FindInChain utilities would be nice, though not blocking. FWIW, I think it can even be done type-safely using _Generic in C11 and templates in C++. A little programming puzzle for someday.

Calling could look something like:

// unsafe version with manual cast
const WGPUMyExtension* extension = (const WGPUMyExtension*) WGPU_FIND_IN_CHAIN(root, WGPUSType_MyExtension);

or

// safe version using _Generic or template to look up the WGPUSType
const WGPUMyExtension* extension;
WGPU_FIND_IN_CHAIN(root, extension);
@kainino0x kainino0x added the non-breaking Does not require a breaking change (that would block V1.0) label Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
non-breaking Does not require a breaking change (that would block V1.0)
Projects
None yet
Development

No branches or pull requests

1 participant