Skip to content

C-style enum sentinel is broken #458

@kvark

Description

@kvark
language = "C"
[enum]
add_sentinel = true

Ends up generating the following enums:

enum WGPUBindingType {
  WGPUBindingType_UniformBuffer = 0,
  WGPUBindingType_StorageBuffer = 1,
  WGPUBindingType_ReadonlyStorageBuffer = 2,
  WGPUBindingType_Sampler = 3,
  WGPUBindingType_SampledTexture = 4,
  WGPUBindingType_StorageTexture = 5,

  Sentinel /* this must be last for serialization purposes. */
};

Problem is that, since these are not enum classes, Sentinel becomes visible everywhere and collides with any other enum right away:

 0:26.45 /mnt/code/firefox/obj-x86_64-pc-linux-gnu/dist/include/mozilla/webgpu/ffi/wgpu_ffi_generated.h:52:3: error: redefinition of enumerator 'Sentinel'
 0:26.45   Sentinel /* this must be last for serialization purposes. */
 0:26.45   ^
 0:26.45 /mnt/code/firefox/obj-x86_64-pc-linux-gnu/dist/include/mozilla/webgpu/ffi/wgpu_ffi_generated.h:43:3: note: previous definition is here
 0:26.45   Sentinel /* this must be last for serialization purposes. */
 0:26.45

We need to either add the prefix to it automatically (e.g. WGPUBindingType_Sentinel_ - would be my preference), or allow the user to control the name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions