#5550 closed defect (fixed)
Different size of long on windows / linux systems
Reported by: | jens.schoenbohm@… | Owned by: | sjoelund.se |
---|---|---|---|
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 Changed 5 years ago by adrpo
comment:2 Changed 4 years ago by sjoelund.se
- Owner changed from lochel to sjoelund.se
- Status changed from new to assigned
comment:3 Changed 4 years ago by sjoelund.se
- Milestone changed from Future to 1.17.0
- Resolution set to fixed
- Status changed from assigned to closed
comment:4 Changed 4 years ago by sjoelund.se
- Summary changed from Different size of long on windows / linus systems to Different size of long on windows / linux systems
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.