Skip to content

Init macros for designated initializers in C++ #579

Description

@Kangz

On bkaradzic/bgfx#3544 there is an example of the following code that doesn't compile in C++ but should be possible to make work if the INIT macros used designated initializers. Maybe we should consider doing this (where designated initializers are availble, so C++17?)

C++ issue, I used named parameters, but WGPU_*_INIT is using struct / unnamed...

		void initBufferBinding(WGPUBindGroupLayoutEntry& _out, uint32_t _binding, WGPUShaderStage _visibility, WGPUBufferBindingType _type, bool _hasDynamicOffset)
		{
			_out =
			{
				.nextInChain      = NULL,
				.binding          = _binding,
				.visibility       = _visibility,
				.bindingArraySize = 0,
				.buffer =
				{
					.nextInChain      = NULL,
					.type             = _type,
					.hasDynamicOffset = _hasDynamicOffset,
					.minBindingSize   = 0,
				},
				.sampler = WGPU_SAMPLER_BINDING_LAYOUT_INIT,
				.texture = WGPU_STORAGE_TEXTURE_BINDING_LAYOUT_INIT,
				.storageTexture = WGPU_STORAGE_TEXTURE_BINDING_LAYOUT_INIT,
			};
		}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions