Opened 4 years ago

Last modified 3 years ago

#6098 accepted defect

(possibly) wrong type mapping for bool in record passed to external object

Reported by: Roman <openmodelica@…> Owned by: Mahder Alemseged Gebremedhin
Priority: blocker Milestone: 1.19.0
Component: Code Generation Version:
Keywords: Cc:

Description

Summary:
A boolean in a record, passed to a external object will result in a wrong C struct for the record. Boolean will be translated to "signed char" instead of "int".
See https://modelica.org/documents/ModelicaSpec34.pdf#page=169

Given a record

record MyRecord

Real MyReal;
Boolean MyBoolean;

end MyRecord;

that will be passed to a function:

function bmaxxAufladung "Aufladung"

output MyRecord mRecord;
external "C" externalCFunction(mRecord);

end bmaxxAufladung;

will result in "MyModelName_functions.h"
typedef struct {

modelica_real _MyReal;
modelica_boolean _MyReal;
} ModelName_MyRecord;

modelica_boolean is defined as "typedef signed char modelica_boolean;" in include/omc/c/openmodelica_types.h

Change History (5)

comment:1 by Francesco Casella, 4 years ago

Component: *unknown*Code Generation
Milestone: Future1.17.0
Owner: changed from somebody to Mahder Alemseged Gebremedhin
Priority: highblocker
Status: newassigned

@mahge390 this should be an easy fix

comment:2 by Mahder Alemseged Gebremedhin, 4 years ago

Status: assignedaccepted

comment:3 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

Rescheduled to 1.18.0

comment:4 by Francesco Casella, 3 years ago

Milestone: 1.18.0

Ticket retargeted after milestone closed

comment:5 by Francesco Casella, 3 years ago

Milestone: 1.19.0

1.18.0 blocker tickets moved to 1.19.0

Note: See TracTickets for help on using tickets.