C++ Logo

liaison

Advanced search

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

From: Jens Maurer <Jens.Maurer_at_[hidden]>
Date: Wed, 12 May 2021 22:06:02 +0200
On 12/05/2021 21.51, Charlie Barto via Liaison wrote:
> But in any case the before/after comparison
>
> extern “C” VkResult vkCreateInstance(const VkInstanceCreateInfo*, const VKAllocationCallbacks*, VkInstance*);
>
> in c++:
>
> VkApplicationInfo appinfo {
> .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
> };
> VkInstanceCreateInfo createInfo {
> .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
> .pApplicationInfo = &appinfo,
> };
> VkInstance instance = 0;
> auto result = vkCreateInstance(&createInfo, nullptr, &instance);
>
> 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);

I'd like to point out that this example is not about lifetime
(full-expression vs. block), but about the fact that in C,
compound literals are lvalues, so you can take their address.

Jens


Received on 2021-05-12 15:06:10