Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#5550 closed defect (fixed)

Different size of long on windows / linux systems

Reported by: jens.schoenbohm@… Owned by: Martin Sjölund
Priority: low Milestone: 1.17.0
Component: Code Generation Version: v1.14.0-dev-nightly
Keywords: Cc:

Description

Hi,
I have the problem, that the same metamodelica code on different os gives different results:

function intSize
output Integer j = 0;
  protected
    Integer i = 1;
  algorithm
    while i > 0 loop
      j := j + 1;
      i := i * 2;
    end while; 
 print(j);
end intSize;

On a windows system the value of j is 31 and on a linux system the value is 63. e.g. This is a problem using the hash function.

As far as I could see, this happens because of the different length of the c type long on different os.

openmodelica_types.h defines

typedef long m_integer

I suggest to use long long for the windows version.

Change History (4)

comment:1 by Adrian Pop, 5 years ago

Those are for the Modelica side, and yes, it seems like a bug.

For MetaModelica we should have 63bit integers for 64bit Windows installer and 31bit integers for the 32bit one:
https://github.com/OpenModelica/OpenModelica/blob/master/OMCompiler/SimulationRuntime/c/meta/meta_modelica_data.h#L81
We use mmc_sint_t and mmc_uint_t for MetaModelica.

comment:2 by Martin Sjölund, 4 years ago

Owner: changed from Lennart Ochel to Martin Sjölund
Status: newassigned

comment:3 by Martin Sjölund, 4 years ago

Milestone: Future1.17.0
Resolution: fixed
Status: assignedclosed

comment:4 by Martin Sjölund, 4 years ago

Summary: Different size of long on windows / linus systemsDifferent size of long on windows / linux systems
Note: See TracTickets for help on using tickets.