snes9xgit / snes9x

Snes9x - Portable Super Nintendo Entertainment System (TM) emulator
http://www.snes9x.com
Other
2.63k stars 453 forks source link

Compile error on Slackware64-current #946

Closed mdinslage closed 3 weeks ago

mdinslage commented 3 weeks ago

Libraries used: snes9x-1.63 glslang-12.1.0 Vulkan-Headers-1.3.246 gcc-14.2.0

Today I tried compiling snes9x-1.63 on Slackware64-current as of Sept. 4, 2024 and ran into these errors


/tmp/SBo/snes9x-1.63/gtk/../external/fmt/include/fmt/core.h:1703:46: note: the temporary was destroyed at the end of the full expression ‘fmt::v8::detail::arg_mapper<fmt::v8::basic_format_context<fmt::v8::appender, char> >().fmt::v8::detail::arg_mapper<fmt::v8::basic_format_context<fmt::v8::appender, char> >::map<std::__cxx11::basic_string<char> >((*(const std::__cxx11::basic_string<char>*)(& std::forward<__cxx11::basic_string<char>&>((* & val)))))’
 1703 |   const auto& arg = arg_mapper<Context>().map(std::forward<T>(val));
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/tmp/SBo/snes9x-1.63/vulkan/vulkan_shader_chain.cpp: In member function ‘void Vulkan::ShaderChain::update_descriptor_set(vk::CommandBuffer, int, int)’:
/tmp/SBo/snes9x-1.63/vulkan/vulkan_shader_chain.cpp:335:13: error: ‘assert’ was not declared in this scope
  335 |             assert(sampler.specifier < (int)pipelines.size());
      |             ^~~~~~
/tmp/SBo/snes9x-1.63/vulkan/vulkan_shader_chain.cpp:4:1: note: ‘assert’ is defined in header ‘<cassert>’; this is probably fixable by adding ‘#include <cassert>’
    3 | #include "stb_image.h"
  +++ |+#include <cassert>
    4 | #include "vulkan/vulkan_enums.hpp"
/tmp/SBo/snes9x-1.63/vulkan/vulkan_shader_chain.cpp:354:13: error: ‘assert’ was not declared in this scope
  354 |             assert(sampler.specifier + 1 < (int)pipelines.size());
      |             ^~~~~~
/tmp/SBo/snes9x-1.63/vulkan/vulkan_shader_chain.cpp:354:13: note: ‘assert’ is defined in header ‘<cassert>’; this is probably fixable by adding ‘#include <cassert>’
/tmp/SBo/snes9x-1.63/vulkan/vulkan_shader_chain.cpp:376:13: error: ‘assert’ was not declared in this scope
  376 |             assert(which_original > -1);
      |             ^~~~~~
/tmp/SBo/snes9x-1.63/vulkan/vulkan_shader_chain.cpp:376:13: note: ‘assert’ is defined in header ‘<cassert>’; this is probably fixable by adding ‘#include <cassert>’
make[2]: *** [CMakeFiles/snes9x-gtk.dir/build.make:392: CMakeFiles/snes9x-gtk.dir/tmp/SBo/snes9x-1.63/vulkan/vulkan_shader_chain.cpp.o] Error 1
make[2]: Leaving directory '/tmp/SBo/snes9x-1.63/gtk/build'
make[1]: *** [CMakeFiles/Makefile2:667: CMakeFiles/snes9x-gtk.dir/all] Error 2
make[1]: Leaving directory '/tmp/SBo/snes9x-1.63/gtk/build'
make: *** [Makefile:136: all] Error 2

and this

make[2]: *** [CMakeFiles/snes9x-gtk.dir/build.make:336: CMakeFiles/snes9x-gtk.dir/tmp/SBo/snes9x-1.63/vulkan/vulkan_texture.cpp.o] Error 1
/tmp/SBo/snes9x-1.63/vulkan/vulkan_context.cpp: In member function ‘bool Vulkan::Context::init_device(int)’:
/tmp/SBo/snes9x-1.63/vulkan/vulkan_context.cpp:236:25: error: ambiguous overload for ‘operator==’ (operand types are ‘vk::PhysicalDevice’ and ‘std::nullptr_t’)

I was able to solve the problem with this patch I created

diff -up snes9x-1.63/vulkan/vulkan_context.cpp.orig snes9x-1.63/vulkan/vulkan_context.cpp
--- snes9x-1.63/vulkan/vulkan_context.cpp.orig  2024-09-05 01:12:37.135747000 -0500
+++ snes9x-1.63/vulkan/vulkan_context.cpp   2024-09-05 01:13:08.614747000 -0500
@@ -2,6 +2,7 @@
 #include <vector>
 #include <string>
 #include "vulkan_context.hpp"
+#include <cassert>

 namespace Vulkan
 {
@@ -233,7 +234,7 @@ bool Context::init_device(int preferred_
         physical_device = device_list[preferred_device];
     }

-    if (physical_device == nullptr)
+    if (physical_device == vk::PhysicalDevice())
     {
         for (auto &device : device_list)
         {

And then adding the necessary #include head to the corresponding files


sed -i '5i #include <cassert>' vulkan/vulkan_texture.cpp
sed -i '5i #include <cassert>' vulkan/vulkan_pipeline_image.cpp
sed -i '5i #include <cassert>' vulkan/vulkan_shader_chain.cpp

Just reporting if this information is useful

Thanks.

mdinslage commented 3 weeks ago

disregard, After updating the Vulkan-Headers to a newer version it compiles fine.

bearoso commented 3 weeks ago

I've fixed everything reported. The code shouldn't rely on cassert being included by the Vulkan headers. It shouldn't be using system Vulkan headers either unless the submodule wasn't checked out. Assigning nullptr to physical_device is undefined behavior, so fixed.