News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

bug: 64 bit compilation issue.

Started by O01eg, July 24, 2015, 05:19:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

O01eg

When trying compile last updates I get error:

Quote
obj/leitung2.cc: In member function 'virtual void leitung_t::info(cbuffer_t&, bool) const':
obj/leitung2.cc:400:69: error: cast from 'powernet_t*' to 'uint32 {aka unsigned int}' loses precision [-fpermissive]
  buf.printf( translator::translate("Net ID: %u\n"), (uint32)get_net() );
...
obj/leitung2.cc: In member function 'virtual void leitung_t::rdwr(loadsave_t*)':
obj/leitung2.cc:454:27: error: cast from 'powernet_t*' to 'uint32 {aka unsigned int}' loses precision [-fpermissive]
   value = (uint32)get_net();

It was entered in commit 8cc188.

It better to output pointer as "%p" without conversion to any int and as I see in virtual void leitung_t::rdwr(loadsave_t*) it stores pointer value in file. Maybe upstream change type of get_net() before from powernet_t* to some identifier?

Branch: devel-new
gcc-4.8.4
Gentoo Linux AMD64

jamespetts

Thank you for that: I have now pushed what I believe to be a fix. Can you test it?

The problem seems to have originated from the loading and saving of a variable enigmatically called "value", relating to the electricity supply. This is actually the pointer of the power network to which a power network component is connected. Trying to remove "long" and "unsigned long" ended up putting it as a uint32 type, which cannot be cast from a 64-bit pointer (at least not without, I assume, the -fpermissive flag).

Oddly, however, although it is loaded, "value" is simply never used. It cannot just be removed, as it would break saved game compatibility. I have just reverted this to "unsigned long", as it does not seem to make any difference what this number is. This anomaly is also present in Standard.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

O01eg

Yep, that file was compiled and I get next error:
Quote
vehicle/simvehicle.cc: In member function 'virtual void air_vehicle_t::set_convoi(convoi_t*)':
vehicle/simvehicle.cc:5877:26: error: cast from 'convoi_t*' to 'uint32 {aka unsigned int}' loses precision [-fpermissive]
  if(leading  &&  (uint32)cnv > 1) {

As I see in upstream they leave "unsigned long" also: https://github.com/aburch/simutrans/blob/master/vehicle/simvehicle.cc#L3961

jamespetts

Splendid, thank you for that. I have now reverted that change - can you try it again and see whether it compiles this time?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

O01eg

Last was changes in "long dr_midi_pos();" to "sint32 dr_midi_pos();" after it all compiles successfuly. Original commit changed only w32_midi.cc.

jamespetts

Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.