Skip to main content
Topic: git pull (13/7) wont compile (Read 3794 times) previous topic - next topic

git pull (13/7) wont compile

Hi,

I cannot compile git pull e5827e997a9d6ce4283c7b660079a3c5db706244 under linux. The problems seems to originate with path_explorer. First of all there is a simple typo on line 11 which causes a necessary header file not to be included:
Code: [Select]
#include <string>
should be
Code: [Select]
#include <string.h>

The greater problem is the inclusion of <mmsystem.h>, which is not under any win32 ifdef in simsys_s.h (line 38) I am not an expert but I thought this was a windows specific header? Moving the line
Code: [Select]
#include <mmsystem.h>
to line 27 (inside the #ifdef _WIN32) does not help since it seems that a lot of called functions then are unavailable.

There is also a problem with the following (gcc-output:)
Code: [Select]
path_explorer.h: In destructor ‘path_explorer_t::halthandle_sorted_heap_t::~halthandle_sorted_heap_t()’:
path_explorer.h:52: error: ‘free’ was not declared in this scope
This is probably connected to simmem.h:10-15
Code: [Select]
#ifdef _MSC_VER
# include <malloc.h>
# define guarded_free free
#else
void guarded_free(void* ptr);
#endif

Here I gave up...
--
OS debian/squeeze - gcc 4.3.3
config.template: linux, sdl, colour_depth=16, debug =3

Re: git pull (13/7) wont compile

Reply #1
What I did to make it compile:

Change the string to string.h

Commented out the mmsystem.h (Too lazy to move it)

Commented out all code that knightly added in simsys_s.cc, and uncommented SDL_GetTicks in dr_time() (Too lazy to place it in an ifdef, as far as I know SDL_GetTicks is good enough on linux/unix, Knightly please correct me if I'm wrong...)

Added path_explorer.cc to SOURCES in Makefile

For reference: complete patch

Code: [Select]
diff --git a/Makefile b/Makefile
index 0cf09c5..53edd4c 100644
--- a/Makefile
+++ b/Makefile
@@ -307,6 +307,7 @@ SOURCES += simware.cc
 SOURCES += simwerkz.cc
 SOURCES += simwin.cc
 SOURCES += simworld.cc
+SOURCES += path_explorer.cc
 SOURCES += sucher/platzsucher.cc
 SOURCES += tpl/debug_helper.cc
 SOURCES += unicode.cc
diff --git a/path_explorer.h b/path_explorer.h
index 0d55358..9cc0208 100644
--- a/path_explorer.h
+++ b/path_explorer.h
@@ -8,7 +8,7 @@
 #ifndef path_explorer_h
 #define path_explorer_h
 
-#include <string>
+#include <string.h>
 
 #include "halthandle_t.h"
 #include "convoihandle_t.h"
diff --git a/simsys_s.cc b/simsys_s.cc
index a514ad0..134e2c3 100644
--- a/simsys_s.cc
+++ b/simsys_s.cc
@@ -35,7 +35,8 @@
 #include <string.h>
 #include <stdlib.h>
 #include <math.h>
-#include <mmsystem.h>
+//#include <mmsystem.h>
+#define LARGE_INTEGER uint64
 
 #ifndef PATH_MAX
 #define PATH_MAX (1024)
@@ -141,7 +142,7 @@ int dr_os_init(const int* parameter)
  atexit(SDL_Quit); // clean up on exit
 
  // Added by : Knightly
- if ( umgebung_t::default_einstellungen.get_system_time_option() == 0 )
+ /*if ( umgebung_t::default_einstellungen.get_system_time_option() == 0 )
  {
  // set precision to 1ms if multimedia timer functions are used
  timeBeginPeriod(1);
@@ -156,7 +157,7 @@ int dr_os_init(const int* parameter)
  umgebung_t::default_einstellungen.set_system_time_option(0); // reset to using multimedia timer
  timeBeginPeriod(1); // set precision to 1ms
  }
- }
+ }*/
 
  return TRUE;
 }
@@ -261,11 +262,11 @@ int dr_os_close(void)
  // SDL_FreeSurface(screen);
 
  // Added by : Knightly
- if ( umgebung_t::default_einstellungen.get_system_time_option() == 0 )
+ /*if ( umgebung_t::default_einstellungen.get_system_time_option() == 0 )
  {
  // reset precision if multimedia timer functions have been used
  timeEndPeriod(1);
- }
+ }*/
 
 
  return TRUE;
@@ -693,7 +694,7 @@ unsigned long dr_time(void)
 {
  // Modified by : Knightly
  // declare and initialize once
- static LARGE_INTEGER t; // for storing current time in counts
+ /*static LARGE_INTEGER t; // for storing current time in counts
  static LARGE_INTEGER f; // for storing performance counter frequency, which is fixed when system is running
  static const bool support_performance_counter = ( QueryPerformanceFrequency(&f) != 0 );
 
@@ -707,10 +708,10 @@ unsigned long dr_time(void)
  {
  // Case : use multimedia timer functions
  return timeGetTime();
- }
+ }*/
 
  // Knightly : this function actually calls timeGetTime()
- // return SDL_GetTicks();
+ return SDL_GetTicks();
 }

Re: git pull (13/7) wont compile

Reply #2
I don't know if it has anythhing to do with my "patch" but the path_explorer system crashes when creating a new line and starting the convoi

Quote
Program received signal SIGFPE, Arithmetic exception.
[Switching to Thread 0x7ff934380700 (LWP 20487)]
0x00000000005e4eb1 in path_explorer_t::compartment_t::step (this=0x2922a48)
    at path_explorer.cc:521
521                  const uint32 projected_iterations = statistic_iteration * time_midpoint / statistic_duration;
(gdb) bt
#0  0x00000000005e4eb1 in path_explorer_t::compartment_t::step (this=0x2922a48)
    at path_explorer.cc:521
#1  0x00000000005e67e9 in path_explorer_t::step () at path_explorer.cc:73
#2  0x00000000005d554c in karte_t::step (this=0x2920ef0) at simworld.cc:3001
#3  0x00000000005d6401 in karte_t::interactive (this=0x2920ef0)
    at simworld.cc:4748
#4  0x00000000005a599d in simu_main (argc=2, argv=0x7fffa0b9df68)
    at simmain.cc:956
#5  0x000000000060f320 in main (argc=2, argv=0x7fffa0b9df68) at simsys_s.cc:779

EDIT: as you may have guessed it is a division by zero...
Also it seems that it does not happen with busses but only with trucks (did not try trains or something else) (it is also possible it just does not happen everytime)

 

Re: git pull (13/7) wont compile

Reply #3
Hi Sanna and Nathan,

I am really sorry. It's my fault -- (1) I forgot to add path_explorer.cc to the Makefile (2) I forgot that SDL is used by versions of other platforms besides Windows, but I added some Windows-specific code, namely, performance counter.

I have already made the necessary changes and pushed them to my forked branch, and have also requested James to kindly merge my commits and pushed back to Github master repository.

Once again, very sorry about that!

As for the division by zero error, I will check it out to see what goes wrong.

Edit :

I have found out what caused the division by zero error. I will make another commit to fix it. Thanks for spotting this, Nathan.

Knightly