编译器错误C2398缩小转换
因此,我已经看过几次这个任务,并且尝试用static_cast(width)和static_cast(高度)包装它,但是它只是产生相同的错误,我不太确定为什么在我看来它int float甚至不需要一个缩小转换。我目前正在学习IMGUI,并且在编译时会遇到此错误 错误C2398元素'1':从“ const int”到“ float”的转换需要缩小转换
这是我的代码
constexpr int WIDTH = 500;
constexpr int HEIGHT = 300;
}
//it is referenced later in this line in a different file that DOES include the header
void gui::Render() noexcept
{
ImGui::SetNextWindowSize({ WIDTH, HEIGHT });
}
//I have attempted to do a simple float conversion but it still screams at me with the same error
So I have seen this quest a few times and I have tried wrapping it with static_cast(WIDTH) and static_cast(HEIGHT) however it just produces the same error and I am not too sure why it seem to me int to float shouldnt even need a narrowing conversion. I am currently learning ImGui and am getting this error when i compile
Error C2398 Element '1': conversion from 'const int' to 'float' requires a narrowing conversion
This is my code
constexpr int WIDTH = 500;
constexpr int HEIGHT = 300;
}
//it is referenced later in this line in a different file that DOES include the header
void gui::Render() noexcept
{
ImGui::SetNextWindowSize({ WIDTH, HEIGHT });
}
//I have attempted to do a simple float conversion but it still screams at me with the same error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论