Code Generation Prototypes

188 views
Skip to first unread message

Robert

unread,
Mar 29, 2016, 2:11:07 PM3/29/16
to YAKINDU User
I've run into an issue with the prototypes generated for a state chart. Maybe I've missed an option somewhere.

The code generates a prototype for a user supplied function as

extern sc_integer xonxoffIface_getTimems(Xonxoff* handle);

It gets used in the code generated for the statechart as follows

static sc_boolean xonxoff_check_main_region_SerialTxRx_Transmit_Stalled_tr1_tr1(const Xonxoff* handle) {
 return (bool_true) && (xonxoffIface_getTimems(handle) - handle->internal.start_state) > handle->iface.XOFF_TIMEOUT;
}

The problem is that means you are now passing a const pointer as a non-const argument. As a result lint gives the following complaint (quite legitimately)

 return (bool_true) && (xonxoffIface_getTimems(handle) - handle->internal.start_state) > handle->iface.XOFF_TIMEOUT;
"src-gen\Xonxoff.c",287  Warning 605:  Increase in pointer capability (arg. no.
    1)

and even if I turn the lint complaint off the compiler refuses to compile it with the following error

   return (bool_true) && (xonxoffIface_getTimems(handle) - handle->internal.start_state) > handle->iface.XOFF_TIMEOUT;
                                                 ^
"C:\Users\E9877365\Documents\solar\IO\EQ-89-caux-modbus-serial-i-o\Code\src-gen\Xonxoff.c",287  Error[Pe167]:
          argument of type "Xonxoff const *" is incompatible with parameter of
          type "Xonxoff *"

Either the xonxoff_check_main_region_SerialTxRx_Transmit_Stalled_tr1_tr1 should be defined with a non-const argument or the operation should be prototyped with a const argument.

An advantage of doing the later is that you would get a compile time complaint if you tried to raise an event from within an operation.

Robert







Andreas Mülder

unread,
Apr 1, 2016, 3:11:33 AM4/1/16
to YAKINDU User
Hi Robert,

thank you very much for the detailed bug report.

You hit a known bug that was introduced in  2.5.0 and will be fixed in the upcoming 2.6.0.
For more details see https://github.com/Yakindu/statecharts/issues/326 (comment #3)

Sorry for any inconvenience,

Andreas

Reply all
Reply to author
Forward
0 new messages