Error C2440: '=': cannot convert from 'vk::ResultValueType<void>::type' to 'vk::Result'

Hi, I’m starting to build my project using Vulkan.

The code below is referenced from “C:\VulkanSDK\\Demos\cube.cpp”, but I just replaced the struct “Demo” with “Vulkan”, in order to simplify the engine I’m creating, because the simpler it is, the faster to raise.

The error is indicated in a comment in the code below, I spent whole day to try to fix it but it’s too difficult. But I’m sure there will be no error if I 100% copy the project from Vulkan’s “cube.cpp”. But the problem is that project is using Win32, I want to use a cross platform project using SDL2, so I’m stuck on this problem.

If this problem is still not solved, then I try to give more detailed but extremely complex details, but here is the simplest question if someone can solve it. Thanks.

People from Google tell that you must use vulkan.hpp but I already use it.

#include <vulkan/vulkan.hpp>
#include <vulkan/vk_sdk_platform.h>

#include "external/linmath.h"


void Vulkan::build_image_ownership_cmd(uint32_t const &i) {
	auto const cmd_buf_info = vk::CommandBufferBeginInfo().setFlags(vk::CommandBufferUsageFlagBits::eSimultaneousUse);
	auto result = swapchain_image_resources[i].graphics_to_present_cmd.begin(&cmd_buf_info);
	VERIFY(result == vk::Result::eSuccess);

	auto const image_ownership_barrier =
		.setSubresourceRange(vk::ImageSubresourceRange(vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1));

		vk::PipelineStageFlagBits::eBottomOfPipe, vk::PipelineStageFlagBits::eBottomOfPipe, vk::DependencyFlagBits(), 0, nullptr, 0,
		nullptr, 1, &image_ownership_barrier);

    // Error C2440: '=': cannot convert from 'vk::ResultValueType<void>::type' to 'vk::Result'
	result = swapchain_image_resources[i].graphics_to_present_cmd.end();
	VERIFY(result == vk::Result::eSuccess);

Solved, I mistakenly double include “vulkan.hpp” from distant lines, I commented the one then problem solved. This topic can be deleted, but can be kept too because including “vulkan.hpp” once is the solution.

@mandaxyz : your “solution” seems a bit odd to me.
CommandBuffer::end() returns vk::ResultValueType<void>::type, which maps either to void (if VULKAN_HPP_NO_EXCEPTIONS is not defined) or vk::Result (if VULKAN_HPP_NO_EXCEPTIONS is defined).
That is, no matter how often you include vulkan.hpp (which actually also holds an include guard), you should always get the very same compiler message here.