Skip to content

Conversation

@joselopeqti
Copy link
Contributor

Introduce __CL_HAS_ANON_UNION__ and __CL_ANON_UNION__ for anonymous union support.
Anonymous unions are supported in C++11 and later versions, but not anonymous structs.
This change explicitly enables anonymous unions for C++11 or later, otherwise, it will fall back to the previous anonymous structs logic.

@CLAassistant
Copy link

CLAassistant commented Oct 2, 2025

CLA assistant check
All committers have signed the CLA.

@Kerilk
Copy link
Contributor

Kerilk commented Oct 2, 2025

Thanks for the contribution, I think this is a good idea.
It would require to update the loader code as well:
https://github.com/KhronosGroup/OpenCL-ICD-Loader/blob/02134b05bdff750217bf0c4c11a9b13b63957b04/loader/icd.h#L185-L189

#if __CL_HAS_ANON_STRUCT__
#define ICD_ANON_UNION_INIT_MEMBER(a) {a}
#else
#define ICD_ANON_UNION_INIT_MEMBER(a) a
#endif

@Kerilk
Copy link
Contributor

Kerilk commented Oct 2, 2025

@karolherbst Would this renaming change cause a problem with the way you use the headers for rusticl?

@karolherbst
Copy link
Contributor

@karolherbst Would this renaming change cause a problem with the way you use the headers for rusticl?

No, the only thing that matters is how the structs look like after preprocessing and this change doesn't change that as the bindings are generated in C mode, not C++.

@joselopeqti
Copy link
Contributor Author

Thanks for the contribution, I think this is a good idea. It would require to update the loader code as well: https://github.com/KhronosGroup/OpenCL-ICD-Loader/blob/02134b05bdff750217bf0c4c11a9b13b63957b04/loader/icd.h#L185-L189

#if __CL_HAS_ANON_STRUCT__
#define ICD_ANON_UNION_INIT_MEMBER(a) {a}
#else
#define ICD_ANON_UNION_INIT_MEMBER(a) a
#endif

I have just pushed a PR for it KhronosGroup/OpenCL-ICD-Loader#264, I guess the CI will pass once this change is merged.

Copy link
Contributor

@Kerilk Kerilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, I think we should accept this.

@bashbaug
Copy link
Contributor

Merging as discussed in the October 14th teleconference.

@bashbaug bashbaug merged commit 6137cfb into KhronosGroup:main Oct 14, 2025
74 checks passed
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.

5 participants