C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] P2174 Status (and a tenuous offer to help)

From: Charlie Barto <Charles.Barto_at_[hidden]>
Date: Wed, 12 May 2021 22:54:25 +0000
Huh, neat.

Does the proposal work for:
    VkInstance instance = 0;
    VkInstanceCreateInfo info {
        .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
        .pApplicationInfo = (VkApplicationInfo[]) {{
            .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
            .pApplicationName = "Hello World",
            .applicationVersion = VK_MAKE_VERSION(0, 1, 0),
            .pEngineName = "No Engine",
            .apiVersion = VK_API_VERSION_1_2
        };
    VkResult result = vkCreateInstance(&info, nullptr, &instance);

(pardon any mismatched brackets :\).


From: Zhihao Yuan <zy_at_[hidden]t>
Sent: Wednesday, May 12, 2021 3:48 PM
To: Charlie Barto <Charles.Barto_at_[hidden]>
Cc: liaison_at_[hidden]pp.org
Subject: RE: [wg14/wg21 liaison] P2174 Status (and a tenuous offer to help)

On Wednesday, May 12, 2021 12:51 PM, Charlie Barto <Charles.Barto_at_[hidden]<mailto:Charles.Barto_at_[hidden]>> wrote:


extern “C” VkResult vkCreateInstance(const VkInstanceCreateInfo*, const VKAllocationCallbacks*, VkInstance*);



in C:

VkInstance instance = 0;

VkResult result = vkCreateInstance(&(VkInstanceCreateInfo){

                .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,

                .pApplicationInfo = &(VkApplicationInfo) {

.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,

                                .pApplicationName = “Hello World”,

                                .applicationVersion = VK_MAKE_VERSION(0, 1, 0),

                                .pEngineName = “No Engine”,

                                .apiVersion = VK_API_VERSION_1_2

                }}, NULL, &instance);



This usecase isn’t supported if the semantics are (T){…} === T{…}

The following is legal given the proposal:

    VkInstance instance = 0;
    VkResult result = vkCreateInstance((VkInstanceCreateInfo[]) {{
        .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
        .pApplicationInfo = (VkApplicationInfo[]) {{
            .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
            .pApplicationName = "Hello World",
            .applicationVersion = VK_MAKE_VERSION(0, 1, 0),
            .pEngineName = "No Engine",
            .apiVersion = VK_API_VERSION_1_2
        }}
    }}, nullptr, &instance);

Although it looks somewhat strange (GCC
forbids array-prvalue -> pointer conversion,
but the standard allows it).

https://godbolt.org/z/7n6rG8orY

Does that work for you?

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________

Received on 2021-05-12 17:54:28