zaimoni / Cataclysm

A post-apocalyptic roguelike. New features relative to C:Whales are scheduled for after 0.2.0, the savefile breaking release.
http://www.bay12forums.com/smf/index.php?topic=174897
Other
27 stars 3 forks source link

Various fixes for issues found with clang compile #139

Closed hirdrac closed 3 years ago

hirdrac commented 3 years ago

Note that not all clang issues found are fixed by these changes and the Makefile has not been changed from gcc.

hirdrac commented 3 years ago

Sorry about that - go ahead and revert that bit. Here's what clang outputs if you're curious (just a warning):

clang++ -Wall -Wextra -Wno-switch -Wno-sign-compare -Wno-unused-variable -Wno-uninitialized -Wno-unused-function -Wno-unused-parameter -O3 -std=gnu++20 -MMD -MP -DCATACLYSM -c bionics.cpp -o obj_cataclysm/bionics.o In file included from bionics.cpp:3: In file included from ./game.h:4: In file included from ./reality_bubble.hpp:4: ./map.h:229:43: warning: instantiation of variable 'cataclysm::discard<std::vector>::x' required here, but no definition is available [-Wundefined-var-template] cataclysm::discard<std::vector >::x.clear(); ^ bionics.cpp:590:32: note: in instantiation of function template specialization 'map::i_at' requested here for (const auto& tmp : g->m.i_at(GPSpos)) { ^ ./enums.h:162:11: note: forward declaration of template entity is here static T x; ^ ./map.h:229:43: note: add an explicit instantiation declaration to suppress this warning if 'cataclysm::discard<std::vector>::x' is explicitly instantiated in another translation unit cataclysm::discard<std::vector >::x.clear(); ^ 1 warning generated.

zaimoni commented 3 years ago

Ok; have pushed relevant counterchanges. (The warning corresponds to a problem that doesn't materially affect our use case).

Since default-initialization is (should be) workable and I'd rather not have tight coupling, I kept the inline keyword but locked down the explicit template instantiations behind a preprocessor define that is undefined.