Wyrmgus icon indicating copy to clipboard operation
Wyrmgus copied to clipboard

Missing include files

Open stoecker opened this issue 2 years ago • 5 comments

To build with openSUSE_Tumbleweed following patch is necessary:

diff -ur Wyrmgus-5.2.3/src/util/assert_util.h Wyrmgus-5.2.3_fix/src/util/assert_util.h
--- Wyrmgus-5.2.3/src/util/assert_util.h        2021-10-20 08:29:11.000000000 +0200
+++ Wyrmgus-5.2.3_fix/src/util/assert_util.h    2021-10-27 17:00:26.491432595 +0200
@@ -26,6 +26,9 @@
 
 #pragma once
 
+#include <source_location>
+#include <string>
+
 namespace wyrmgus {
 
 inline std::string get_source_relative_filepath_string(const std::string &filepath)

The first of these two probably needs to be surrounded with the same #ifdefs as later in the file.

stoecker avatar Oct 27 '21 15:10 stoecker

Thanks for the info! Do you know in which .cpp file the compilation fails?

Those headers should already be included indirectly through the stratagus.h header, which should be included in every .cpp file (but it is missing in one of them).

Andrettin avatar Oct 27 '21 15:10 Andrettin

As far as I remember the first error I've seen was in assert_util.cpp.

stoecker avatar Oct 27 '21 15:10 stoecker

Sorry for the delay in responding.

It is strange that the error is present in assert_util.cpp, since that includes stratagus.h, which in turn includes pch.h, which then includes and <source_location>. I'm not sure what could be causing this issue, especially since the automatic compilation workflow is working without any problems.

Andrettin avatar Nov 03 '21 20:11 Andrettin

Thanks for the info! Do you know in which .cpp file the compilation fails?

The error message:

[ 78s] In file included from /home/abuild/rpmbuild/BUILD/Wyrmgus-5.2.4/src/util/assert_util.cpp:29, [ 78s] from /home/abuild/rpmbuild/BUILD/Wyrmgus-5.2.4/build/CMakeFiles/wyrmgus.dir/Unity/unity_util_cxx.cxx:5: [ 78s] /home/abuild/rpmbuild/BUILD/Wyrmgus-5.2.4/src/util/assert_util.h:43:50: error: 'source_location' in namespace 'std' does not name a type [ 78s] 43 | inline std::string get_assert_message(const std::source_location &location) [ 78s] | ^~~~~~~~~~~~~~~ [ 78s] /home/abuild/rpmbuild/BUILD/Wyrmgus-5.2.4/src/util/assert_util.h:1:1: note: 'std::source_location' is defined in header '<source_location>'; did you forget to '#include <source_location>'? [ 78s] +++ |+#include <source_location>

Full log: build-log.txt

susnux avatar Dec 06 '21 12:12 susnux

I think I understand the reason for the issue now. I had made a mistake in the pch.h file, only including <source_location> if __cpp_lib_source_location were defined. But the latter is defined either in <source_location> itself, or in .

So whether this worked was compiler-dependent, if the C++ standard library headers for that implementation included directly or indirectly before we got to the <source_location> check.

I've fixed this issue now by replacing that condition with a check to __has_include<source_location> (in my two latest commits).

I hope this works!

Andrettin avatar Mar 05 '22 08:03 Andrettin