Skip to main content
Topic: Build-on-Linux patches. (Read 2924 times) previous topic - next topic

Build-on-Linux patches.

James, a whole bunch of patches to get the head of your 'devel' branch compiling on Linux are on my jp-devel branch (plus one pair of cosmetic change and one other change).  Please pull them.  Bernd, you probably want to pull them too, as I think some of this is fixing your recent work.

In future, things to remember:
1 -- gcc doesn't like "const" on non-pointer non-reference non-object function return types, as it's redundant; spews warnings.
2 -- gcc *requires* friend declarations to use the "cl****" keyword  ("friend cl**** foo;" instead of "friend foo;")
3 -- check your included header files for the non-MSVC case whenever you use strcpy or strlen; this is the second time I've run into the same issue.  You need <string.h>.  (Edit: I think I had to include <sys/stat.h> somewhere too, due to the use of struct stat.)

Someone had accidentally failed to add gui/components/gui_table.h to the Makefile, so I fixed that too.  

The cosmetic changes:
- rearranges method order in gui/components/gui_table.h so that forward declarations are not needed
- removes non-functional method from list_t<> in gui/components/gui_table.h

The final change (in gui_table.h): delete_item is using delete[], but all the subcl****es use new (no []) to create items.  This is a big no-no, so I fixed it.

Re: Build-on-Linux patches.

Reply #1
Oops. Sorry. I solved conflicts with James' devel branch by using my local gui_table.h...
Meanwhile I extracted list_tpl to tpl/list_tpl.h and I was wondering why James brought it back in gui_table.h.
I'll incorporate your changes manually again ...
The journey is the reward!

Re: Build-on-Linux patches.

Reply #2
Oops. Sorry. I solved conflicts with James' devel branch by using my local gui_table.h...
Meanwhile I extracted list_tpl to tpl/list_tpl.h and I was wondering why James brought it back in gui_table.h.
I'll incorporate your changes manually again ...

Well, on your branch there are more fixes needed....

(1)
#include <sys/stat.h>
is needed in
gui/savegame_frame.h

(Applied in my tree).

(2) Also, you're using strlwr in gui/loadsave_frame.h.  strlwr does not exist under my version of Linux, causing compilation failures.  You have to implement it yourself if you really want to.

In addition please note that filenames are case-sensitive under Linux; lowercasing for similarity-comparison purposes is OK but you can't lowercase anywhere else, certainly not when displaying the name.  It looks like you're lowercasing when displaying the name.

Commented out the uses of strlwr in my tree.

Incidentally, there's a potential buffer overflow, though it's in standard.  The pak name could be more than 1024 characters (not that that's a good idea, but it's possible) -- practically everything having to do with filenames needs painfully careful work with dynamically allocated buffers to be portable.  Maybe I'll fix it sometime.

 

Re: Build-on-Linux patches.

Reply #3
simutrans has in some implementation defined string routines in cstirng_t.h. However, since myGame.sve and Mygame.sve and perfectly valid different filenames under unix, I would only use STRICMP which does a caseless compare on any platform within smutrans.

Re: Build-on-Linux patches.

Reply #4
James, my jp-devel branch has two more compilation fixes for your devel branch (both cases of <string.h> missing).  Please pull.