832 views
in Embedded Wizard Studio by
Dear all,

If i attempt to pass an array on native statement as in the example below:

array int8 ledStatus[6];
native ( ledStatus )
{
    ledStatus[0] = LedStatus[0];
    ledStatus[1] = LedStatus[1];
    ledStatus[2] = LedStatus[2];
    ledStatus[3] = LedStatus[3];
    ledStatus[4] = LedStatus[4];
    ledStatus[5] = LedStatus[5];
}

I get this error during building the profile:

[27.10.2017 14:20:03] Information Generating code for the profile 'STM32F767' ...
[27.10.2017 14:20:04] Error tmScreenMain::LEDPage.GetRequest (15:10) : Missing '[' after the name of the local array 'ledStatus'.
 

As reported at the following page https://doc.embedded-wizard.de/native-statement?v=8.20 the opeartion it seems to be possible.

Could you help me please?

Waiting for your kind reply.

Thanks

Best regards

Gianni Perugini

1 Answer

+1 vote
by

Hello Gianni,

first at all, thank you for the report. You have detected an error in Chora compiler. We will fix it with the next version. As simple workaround, just remove the parameter ledStatus in the native statement. For example:

array int8 ledStatus[6];
native
{
    ledStatus[0] = LedStatus[0];
    ledStatus[1] = LedStatus[1];
    ledStatus[2] = LedStatus[2];
    ledStatus[3] = LedStatus[3];
    ledStatus[4] = LedStatus[4];
    ledStatus[5] = LedStatus[5];
}

The parameter in native statement is just a hint to help the Chora compiler to identify, which variables/arrays are used in native code. In this manner, the variables are not eliminated, etc. But don't worry, since you surely use the array within the method, it will be not eliminated. You should also pre-initialize the array with some default value. Otheriwse Chora will report an error due to usage of eventually not initialized array. Better is:

array int8 ledStatus[6];
var int32  i;

for ( i = 0; i < ledStatus.length; i = i + 1 )
  ledStatus[i] = 0;

native
{
    ledStatus[0] = LedStatus[0];
    ledStatus[1] = LedStatus[1];
    ledStatus[2] = LedStatus[2];
    ledStatus[3] = LedStatus[3];
    ledStatus[4] = LedStatus[4];
    ledStatus[5] = LedStatus[5];
}

Best regards

Paul Banach

by
Dear Paul,

thanks for your answer. Yes, I tried to remove the array parameter in the native argument list and I checked that everything works fine.

Best regards

Gianni Perugini

Ask Embedded Wizard - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...