Skip to content

Incorrect constructor usage for vk::DescriptorSetLayoutCreateInfo in documentation vs source code (initialization error) #275

@XavierBeheydt

Description

@XavierBeheydt

Problem

The line

vk::DescriptorSetLayoutCreateInfo layoutInfo({}, 1, &uboLayoutBinding);

appears in the documentation (e.g. in en/05_Uniform_buffers/00_Descriptor_set_layout_and_buffer.adoc). However, this usage leads to a compilation error when compiled as shown, with clang reporting:

Cannot initialize a member subobject of type 'const void *' with an rvalue of type 'int' clang(init_conversion_failed)

Details

  • The code in the documentation differs from the code in the associated source file attachments/22_descriptor_layout.cpp, which uses:
    vk::DescriptorSetLayoutCreateInfo layoutInfo{.bindingCount = 1, .pBindings = &uboLayoutBinding};
  • The constructor called in the documentation does not match the types expected for the vk::DescriptorSetLayoutCreateInfo, resulting in a conversion/init error on the {}/int argument.
  • This creates confusion for users following the documentation, as the sample code fails to compile while the sample source does work.

Recommendation

  • Update the documentation to match the working code from attachments/22_descriptor_layout.cpp.
  • Use explicit member initialization via the designated initializer list for increased clarity and reduced errors:
    vk::DescriptorSetLayoutCreateInfo layoutInfo{.bindingCount = 1, .pBindings = &uboLayoutBinding};
  • Optionally, provide a short explanation on constructor differences for clarity.

CC: Documentation maintainers


References:

Metadata

Metadata

Assignees

No one assigned

    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