简体   繁体   中英

I'm getting tautological compiler errors. How am I supposed to fix “argument of type ”X“ is incompatible with parameter of type ”X"?

The specific details in my case: I'm using MSVC with AMD's vulkan memory allocator , which is a stb-style single header file. (So you include it in your project like:

#define VMA_IMPLEMENTATION
#include "vk_mem_alloc.h"

within a single compilation unit to compile it, and just

#include "vk_mem_alloc.h"

in any file that needs to use it.)

Anyways:

Some examples of specific errors I'm getting are:

argument of type "VmaDeviceMemoryBlock *" is incompatible with parameter of type "VmaDeviceMemoryBlock *"

and

a value of type "VmaSuballocationType" cannot be assigned to an entity of type "VmaSuballocationType"

and

declaration is incompatible with "void VmaBlockMetadata::PrintDetailedMap_Allocation(VmaJsonWriter &json, VkDeviceSize offset, VmaAllocation hAllocation) const"

when the definition is

void VmaBlockMetadata::PrintDetailedMap_Allocation(class VmaJsonWriter& json,
    VkDeviceSize offset,
    VmaAllocation hAllocation) const

These errors, as well as many others that aren't obviously broken, absolutely litter the file. Even stranger, I can build the program and it compiles and runs without issue. Its populating of my error window with this noise is totally undermining the error window's usefulness. I'm also now getting other strange errors throughout my code, and I'm unsure how to proceed.

I got this exact same set of errors using visual studio 2019. The error in my case was using uniform initialization with an implicit cast.

I needed to change

uint32_t uniformOffset{ pad_uniform_buffer_size(sizeof(GPUSceneData)) * frameIndex };

to

uint32_t uniformOffset{ static_cast<uint32_t>(pad_uniform_buffer_size(sizeof(GPUSceneData)) * frameIndex) };

because pad_uniform_buffer_size returns size_t and I was trying to implicity cast it to uint32_t with uniform initialization.

I have no idea why the error manifested itself in that vma file, but this was the solution in my case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM