Skip to content

Conversation

trbabb
Copy link

@trbabb trbabb commented Aug 23, 2025

On OSX clang when building for wgpu with -DIMGUI_IMPL_WEBGPU_BACKEND_DAWN=1, the following errors occur:

theta/thirdparty/imgui/imgui_impl_wgpu.cpp:400:13: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
  400 |             "Dear ImGui Vertex buffer",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |             {
  401 | #if defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN) || defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  402 |             WGPU_STRLEN,
      |             ~~~~~~~~~~~
      |                        }
theta/thirdparty/imgui/imgui_impl_wgpu.cpp:427:13: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
  427 |             "Dear ImGui Index buffer",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |             {
  428 | #if defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN) || defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  429 |             WGPU_STRLEN,
      |             ~~~~~~~~~~~
      |                        }
theta/thirdparty/imgui/imgui_impl_wgpu.cpp:639:9: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
  639 |         "Dear ImGui Uniform buffer",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |         {
  640 | #if defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN) || defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  641 |         WGPU_STRLEN,
      |         ~~~~~~~~~~~
      |                    }

The definition for a wgpu BufferDescriptor is:

typedef struct WGPUBufferDescriptor {
    WGPUChainedStruct * nextInChain;
    WGPUStringView label;
    WGPUBufferUsage usage;
    uint64_t size;
    WGPUBool mappedAtCreation;
} WGPUBufferDescriptor WGPU_STRUCTURE_ATTRIBUTE;

and for WGPUStringView:

typedef struct WGPUStringView {
    WGPU_NULLABLE char const * data;
    size_t length;
} WGPUStringView WGPU_STRUCTURE_ATTRIBUTE;

In order for the length parameter to be included in the string view, braces are needed around that parameter.

@ocornut
Copy link
Owner

ocornut commented Aug 26, 2025

Have you tried with Emscripten and other backends?

@trbabb
Copy link
Author

trbabb commented Aug 26, 2025

I haven't— is there a test I can run?

@ocornut
Copy link
Owner

ocornut commented Aug 26, 2025

I haven't— is there a test I can run?

There are examples apps running on Emscripten and supposedly Dawn, although the general status of it is a mess partly because there are PR coming from every direction, mostly #8381, but I myself don't have easy TL;DR; steps and compatibility tables to understand what's going on with those evolving API.

@ocornut
Copy link
Owner

ocornut commented Aug 26, 2025

The CI test for Emscripten fails on this with latest Emscripten:
https://github.com/ocornut/imgui/actions/runs/17170197464/job/48930521396?pr=8898

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

Successfully merging this pull request may close these issues.

2 participants