Jump to content

Struct array by reference


Roman Midi-Opa
 Share

Recommended Posts

Hello,

 

I take a array of struct to organize my data and want to reset this data array in a seperat function,

When I do so I get a compiler warning like this:expect struct is data * baut argument is of struct data *"

 

in mwvb.c

 

static midi_waveboard_cards wtbCard[MIDI_WAVEBOARD_CARD_NUM];

 

function init() {

....

do something

     MIDI_WAVEBOARD_Card_Reset(&wtbCard[0], k);

...

The result is  that data in the strust[array] are not changed.

}

 

 

void MIDI_WAVEBOARD_Card_Reset(midi_waveboard_cards * wtbCard[0],u8 resCard ) {

 

do something

 

}

 

Can somebody help.

 

Greetings

 

Roman

 

 

Link to comment
Share on other sites

Hi

 

the trouble with this topic is going on.

 

Hereafter the debug output (cutted by some line):

 

[17952.719] reset
[17954.801] [init] K Emu : 0
[17954.801] [init] Emucount : 3
[17954.802] [initCard] CardNum : 0
[17954.802] [initCard] I : 0
[17954.803] [initCard] PartGrp : 1
[17954.803] [initCard] PartPrg : 1
[17954.803] [initCard] CardNum : 0
[17954.803] [initCard] I : 1
[17954.804] [initCard] PartGrp : 1
[17954.804] [initCard] PartPrg : 1
[17954.804] [initCard] CardNum : 0
[17954.805] [initCard] I : 2
[17954.805] [initCard] PartGrp : 1
[17954.806] [initCard] PartPrg : 1
[17954.806] [initCard] CardNum : 0
[17954.807] [initCard] I : 3
[17954.807] [initCard] PartGrp : 1
[17954.807] [initCard] PartPrg : 1
[17954.808] [initCard] CardNum : 0
snip.......
[17954.821] [initCard] I : 13
[17954.821] [initCard] PartGrp : 1
[17954.822] [initCard] PartPrg : 1
[17954.822] [initCard] CardNum : 0
[17954.822] [initCard] I : 14
[17954.823] [initCard] PartGrp : 1
[17954.823] [initCard] PartPrg : 1
[17954.823] [initCard] CardNum : 0
[17954.824] [initCard] I : 15
[17954.824] [initCard] PartGrp : 1
[17954.824] [initCard] PartPrg : 1
[17954.824] [sNDBANK_DATA] ix : 1
[17954.825] [sNDBANK_DATA] value : 0
[17954.825] [sNDBANK_DATA] Result->prgnum : 1
[17954.826] [sNDBANK_DATA] Result->banknum : 0
[17954.827] [sNDBANK_DATA] Result->name : GrandPno
snip...
[17954.829] [afterInitCard] CardNum : 0
[17954.829] [afterInitCard] I : 0
[17954.829] [afterInitCard] PartGrp : 1
[17954.831] [afterInitCard] PartPrg : 1
[17954.831] [afterInitCard] CardNum : 0
[17954.831] [afterInitCard] I : 1
[17954.832] [afterInitCard] PartGrp : 1
[17954.832] [afterInitCard] PartPrg : 1
[17954.833] [afterInitCard] CardNum : 0
[17954.834] [afterInitCard] I : 2
[17954.834] [afterInitCard] PartGrp : 1
[17954.834] [afterInitCard] PartPrg : 1
[17954.835] [afterInitCard] CardNum : 0
[17954.835] [afterInitCard] I : 3
[17954.835] [afterInitCard] PartGrp : 1
[17954.836] [afterInitCard] PartPrg : 1
[17954.836] [afterInitCard] CardNum : 0
snip.....

[17954.849] [afterInitCard] I : 13

[17954.848] [afterInitCard] PartGrp : 1
[17954.848] [afterInitCard] PartPrg : 1
[17954.849] [afterInitCard] CardNum : 0
[17954.849] [afterInitCard] I : 14
[17954.849] [afterInitCard] PartGrp : 1
[17954.849] [afterInitCard] PartPrg : 1
[17954.849] [afterInitCard] CardNum : 0
[17954.849] [afterInitCard] I : 15
[17954.849] [afterInitCard] PartGrp : 1
[17954.850] [afterInitCard] PartPrg : 0
[17954.850] [midi_labels] size of sndData : 7924
[17954.850] [midi_labels] sndDataArrayCount : 566
[17954.850] Init DHCP
[17954.937] [network_device_init] PHY initialized
[17959.843] SD Card not found

 

As you can see the last PartPrg is not changed after init. What could be happens?

 

BL excluded is = 3FFF; Reached that the border of first memory block?

 

It would be great if you could help me.

 

Roman

Edited by roman01
Link to comment
Share on other sites

It's really hard to guess what your problem is unless you show some actual source and the exact compiler error. Anyways, here's a working version if what I guess you are trying to do, maybe that helps.

 

typedef struct {

    int foo;

} foo_t;


foo_t bla[14];


void doIt(foo_t *data) {

    data[1].foo++;

}


extern "C" void APP_Init(void) {

    doIt((foo_t*)&bla);

    Log("%d", bla[1].foo); // outputs "1"

    doIt((foo_t*)&bla);

    Log("%d", bla[1].foo); // outputs "2"
}

Link to comment
Share on other sites

I found the memory command in MIDI-Studio and enclose the output:

 

[19295.490] memory
[19295.493] Dumping the umm_heap...
[19295.494] |0x2007d328|B     0|NB     1|PB     0|Z     1|NF   850|PF     0|
[19295.494] |0x2007d334|B     1|NB     8|PB     0|Z     7|
[19295.495] |0x2007d388|B     8|NB    15|PB     1|Z     7|
[19295.496] |0x2007d3dc|B    15|NB    22|PB     8|Z     7|
[19295.496] |0x2007d430|B    22|NB    29|PB    15|Z     7|
[19295.497] |0x2007d484|B    29|NB    36|PB    22|Z     7|
[19295.497] |0x2007d4d8|B    36|NB   122|PB    29|Z    86|
[19295.498] |0x2007d8e0|B   122|NB   129|PB    36|Z     7|
[19295.499] |0x2007d934|B   129|NB   215|PB   122|Z    86|
[19295.500] |0x2007dd3c|B   215|NB   222|PB   129|Z     7|
[19295.500] |0x2007dd90|B   222|NB   393|PB   215|Z   171|
[19295.501] |0x2007e594|B   393|NB   400|PB   222|Z     7|
[19295.501] |0x2007e5e8|B   400|NB   571|PB   393|Z   171|
[19295.502] |0x2007edec|B   571|NB   578|PB   400|Z     7|
[19295.502] |0x2007ee40|B   578|NB   664|PB   571|Z    86|
[19295.503] |0x2007f248|B   664|NB   671|PB   578|Z     7|
[19295.503] |0x2007f29c|B   671|NB   757|PB   664|Z    86|
[19295.505] |0x2007f6a4|B   757|NB   764|PB   671|Z     7|
[19295.505] |0x2007f6f8|B   764|NB   850|PB   757|Z    86|
[19295.506] |0x2007fb00|B   850|NB     0|PB   764|Z   344|NF     0|PF     0|
[19295.507] Total Entries    18    Used Entries    18    Free Entries     0
[19295.508] Total Blocks   1193    Used Blocks    849    Free Blocks    344
[19295.508] Size of umm_heap is 14328 bytes, used: 10188 bytes, free: 4128 bytes

 

Sorry for delay in report this.

 

There are no compiler errors.

 

Roman

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...