[crossfire] Building in C++?

Steven Johnson shjohnson.pi at gmail.com
Fri May 27 13:19:55 CDT 2022


I think this is a good idea. I was able to build and run crossfire server
with minimal changes on the cpp-buld branch.

Here's my small patch:
- fix building in a 'build' directory
- Add 'build' to .gitignore
- Fix .gitignore to ignore the .cpp version of common/arch_types_valid.c

diff --git a/.gitignore b/.gitignore
index cdb60bf9..bec59837 100644
--- a/.gitignore
+++ b/.gitignore
@@ -517,7 +517,8 @@
 /utils/ylwrap
 Makefile
 Makefile.in
-common/arch_types_valid.c
+build
+common/arch_types_valid.cpp
 cov-int/
 cscope.*
 doc/playbook/handbook.idx
diff --git a/common/Makefile.am b/common/Makefile.am
index 9b08a564..682c0f5c 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -74,7 +74,7 @@ libcross_a_SOURCES = \
        utils.cpp

 loader.cpp:
-       $(LEX) -i -o loader.cpp loader.l
+       $(LEX) -i -o loader.cpp $(top_srcdir)/common/loader.l

 EXTRA_DIST = README is_valid_types_gen.py
 AM_CPPFLAGS = -I$(top_srcdir)/include -DDATADIR=\"$(pkgdatadir)\"
-DCONFDIR=\"$(pkgconfdir)\" \
diff --git a/random_maps/Makefile.am b/random_maps/Makefile.am
index 65e1b3d9..7562133b 100644
--- a/random_maps/Makefile.am
+++ b/random_maps/Makefile.am
@@ -29,7 +29,7 @@ EXTRA_DIST = \
        main.cpp

 reader.cpp:
-       $(LEX) -P rm -o reader.cpp reader.l
+       $(LEX) -P rm -o reader.cpp $(top_srcdir)/random_maps/reader.l

 AM_CPPFLAGS = -I$(top_srcdir)/include -I${top_srcdir}/include/random_maps

On Fri, May 27, 2022 at 9:46 AM Nicolas Weeger <nicolas.weeger at laposte.net>
wrote:

> Hello.
>
>
> I just pushed branch "cpp-build" which changes all .c files to .cpp files.
> The
> only other changes are what was required for correctly building (adding
> some
> casts, renaming a few variables, things like that).
>
> Functionally, everything is the same.
>
>
> I'd like to merge those changes to master, but well, I'd like to get
> opinions
> before.
>
>
> I don't plan on migrating to a full C++ code base with classes,
> inheritance &
> other things, the current code is fine.
>
> I do plan to use C++ to replace some home-grown things (lists handling
> mostly
> - for new code, I don't want to always have to realloc() and check size, a
> std::vector is enough for that), and to solve issues with object* items
> being
> free'd while still referenced (with our nice check on "count ==
> saved_count"
> here and there urgh).
>
>
>
> Regards
>
>
> Nicolas_______________________________________________
> crossfire mailing list
> crossfire at metalforge.org
> http://mailman.metalforge.org/mailman/listinfo/crossfire
> IRC: http://crossfire.real-time.com/irc/index.html
> Discord: http://crossfire.real-time.com/discord/index.html
> Project Site: https://sourceforge.net/projects/crossfire/
> Wiki: http://wiki.cross-fire.org/
> Website: http://crossfire.real-time.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.metalforge.org/pipermail/crossfire/attachments/20220527/ffa19bd4/attachment.htm>


More information about the crossfire mailing list