#1444 updated the XML file to add cl_icd_dispatch as a requirement for the cl_loader_layers extension.
This seemed like the right thing to do - see https://github.com/KhronosGroup/OpenCL-Docs/pull/1444/files#r2283135496 - but it causes issues with the generated headers, because it causes another typedef to be generated after the structure definition, which is not valid for some C versions.
In file included from /__w/OpenCL-Headers/OpenCL-Headers/tests/test_cl_layer.h.c:25:
/__w/OpenCL-Headers/OpenCL-Headers/CL/cl_layer.h:59:33: error: redefinition of typedef 'cl_icd_dispatch' [-Werror=pedantic]
59 | typedef struct _cl_icd_dispatch cl_icd_dispatch;
| ^~~~~~~~~~~~~~~
In file included from /__w/OpenCL-Headers/OpenCL-Headers/CL/cl_layer.h:24:
/__w/OpenCL-Headers/OpenCL-Headers/CL/cl_icd.h:332:3: note: previous declaration of 'cl_icd_dispatch' with type 'cl_icd_dispatch' {aka 'struct _cl_icd_dispatch'}
332 | } cl_icd_dispatch;
| ^~~~~~~~~~~~~~~
How do we want to fix this? Some options to consider:
- Remove the requirement from the XML file, so the duplicate typedef will not be generated in the extension headers.
- Remove the typedef from the structure definition in
cl_icd.h, so the generated typedef is not a duplicate. Note: This could break code that is including cl_icd.h but not cl_layer.h and expecting the typedef to be present.
- Do not include
cl_icd.h from cl_layer.h. Note: While this would probably work for some usages, it'd still be a problem if both headers are included in the "wrong" order, and most layers will want to include both headers.
- Add a special case in the header generation script to skip generating the duplicate typedef.
I don't like any of these options, so I'm hoping there's another alternative to consider. Thanks!
CC: @Kerilk @RocketRide9
#1444 updated the XML file to add
cl_icd_dispatchas a requirement for thecl_loader_layersextension.This seemed like the right thing to do - see https://github.com/KhronosGroup/OpenCL-Docs/pull/1444/files#r2283135496 - but it causes issues with the generated headers, because it causes another typedef to be generated after the structure definition, which is not valid for some C versions.
How do we want to fix this? Some options to consider:
cl_icd.h, so the generated typedef is not a duplicate. Note: This could break code that is includingcl_icd.hbut notcl_layer.hand expecting the typedef to be present.cl_icd.hfromcl_layer.h. Note: While this would probably work for some usages, it'd still be a problem if both headers are included in the "wrong" order, and most layers will want to include both headers.I don't like any of these options, so I'm hoping there's another alternative to consider. Thanks!
CC: @Kerilk @RocketRide9