如何在Visual Studio 2019中修复"[member variable that is a vulkan struct] is uninitialized. Always initiali



我从Visual Studio 2017转换为2017年,我遇到了以前从未得到的警告。如果我有一个vulkan型成员变量(即vkcommandpool,vkbuffer等(,该变量未在默认构造函数中初始化,则我会在我的问题标题中列出警告。

我尝试过

之类的语句
this->buffer = {};

this->buffer = 0;

,但似乎都没有做任何事情。

示例类:

class Example {
    private:
       VkBuffer buffer;
    public:
       // warning comes from here
       Example() {
           // NOTE: even with initialization in the constructor, I STILL get a warning 
           this->buffer = 0;
           this->buffer = {};
       }
       // calls init with parameters
       Example(/* parameters */) {
         // implementation not relevant to the question
       }
       void init(/* parameters */) {
         // implementation not relevant to the question
       }
};

进一步的测试表明,我的计算机上的智能素有点挑剔,需要一段时间才能更新。重新启动Visual Studio并进行完整的清洁 重建后,似乎可以在构造函数标题中初始化Vulkan变量:

Example() : buffer() { }

或功能主体:

Example() : { 
    this->buffer = {};
}

相关内容

最新更新