[NECTO Studio 2.0, mikroC AI ARM Compiler] wrong initialization of a struct

Fully featured ARM compilers available on Windows, Linux, and macOS.
Post Reply
Author
Message
frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

[NECTO Studio 2.0, mikroC AI ARM Compiler] wrong initialization of a struct

#1 Post by frank.malik » 19 Jul 2022 17:23

Hello,

I have a strange behaviour of the compiler, resulting in a wrong initialization of a struct.
Here is the simple program: Please note the order of the designated initializer in the initialization.

Code: Select all

/**
 * @file main.c
 * @brief Main function for StructInitialization application.
 */

typedef struct 
{
    int var1;
    int var2;
    int var3;
    int var4;
} my_struct_t ;

my_struct_t a = {
    .var1 = 1,
    .var2 = 2,
    .var4 = 5,
    .var3 = 7,
} ;

int main(void)
{
    /* Replace with your application code */
    while (1)
    {
        a.var1 = 0 ;
    }

    return 0;
}
The expected output at the end of the program would be ( if printed out ):

Code: Select all

    var1 : 0
    var2 : 2
    var3 : 7
    var4 : 5
However, the simulator under NECTO Studio shows the following result:

Code: Select all

    var1 : 0
    var2 : 2
    var3 : 5
    var4 : 7
This behavior is proven by another program, and with the debugger and a real board.
Please advice.
best regards
Frank
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: [NECTO Studio 2.0, mikroC AI ARM Compiler] wrong initialization of a struct

#2 Post by filip » 21 Jul 2022 10:40

Hi,

Can you please tell me which MCU are you using ?

Regards,
Filip.

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: [NECTO Studio 2.0, mikroC AI ARM Compiler] wrong initialization of a struct

#3 Post by frank.malik » 21 Jul 2022 17:32

Hi Filip,

yes, your are right, I should have mentioned my configuration. Here it is.

Fusion for STM32 v8
mikroC AI for ARM
mikroSDK v.2.6.0
STM32F407ZG
CODEGRIP
168MHz#
no display

best regards
Frank
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: [NECTO Studio 2.0, mikroC AI ARM Compiler] wrong initialization of a struct

#4 Post by filip » 11 Aug 2022 14:43

Hi,

I have reproduced this issue and notified our developers, hopefully they will have a solution soon.

I apologize for the inconvenience caused by this.

Regards,
Filip.

Post Reply

Return to “ARM AI Compilers”