gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > Apex Audio System types and data structures

#44110 - booger - Mon May 30, 2005 1:21 pm

I'm having a bit of a issue with a very simple task, but since I somehow can't get it to work properly, I turn myself to this forum.

The thing is, I just like to make a static list of pointers to AAS (Apex Audio System) sound samples, but my compiler (DevkitARM) refuses to do it.

Here's a snippet of my code:
Code:
extern const AAS_s8* const AAS_DATA_SFX_START_8bit_KungFu_Hit;

const AAS_s8* sound_items[] =
{
   AAS_DATA_SFX_START_8bit_KungFu_Hit
};


The error message I get when compiling:
ticker.c:28: error: initializer element is not constant
ticker.c:28: error: (near initialization for `sound_items[0]')

Is there anyone who knows what might be wrong?

#44117 - strager - Mon May 30, 2005 3:13 pm

booger wrote:

Here's a snippet of my code:
Code:
extern const AAS_s8* const AAS_DATA_SFX_START_8bit_KungFu_Hit;

const AAS_s8* sound_items[] =
{
   AAS_DATA_SFX_START_8bit_KungFu_Hit
};



Where did you learn to code C from?!?!

Code:

extern const AAS_s8 *AAS_DATA_SFX_START_8bit_KungFu_Hit;

const AAS_s8 *sound_items[] =
{
    AAS_DATA_SFX_START_8bit_KungFu_Hit,
    NULL /* #define NULL ((void *)0) */
};


ALWAYS put null at the end of an array of pointers, so that your code knows where the end of the list is.


Last edited by strager on Mon May 30, 2005 4:44 pm; edited 1 time in total

#44123 - booger - Mon May 30, 2005 4:08 pm

strager: yes, I know about that; this was just a quick example to illustrate my problem - which remains..

#44128 - strager - Mon May 30, 2005 4:46 pm

Code:

extern const AAS_s8 *AAS_DATA_SFX_START_8bit_KungFu_Hit;

const AAS_s8 *sound_items[] =
{
    &AAS_DATA_SFX_START_8bit_KungFu_Hit,
    NULL /* #define NULL ((void *)0) */
};


Might work. Don't think so, though.

#44131 - booger - Mon May 30, 2005 4:48 pm

OK! Found it myself.. I guess my C-skills are a bit rusty nowadays!
The structure should look like this:
Code:
const AAS_s8 **list[] =
{
   &AAS_DATA_SFX_START_8bit_KungFu_Hit,
   NULL,
};

#44135 - strager - Mon May 30, 2005 4:52 pm

booger wrote:
OK! Found it myself.. I guess my C-skills are a bit rusty nowadays!
The structure should look like this:
Code:
const AAS_s8 **list[] =
{
   &AAS_DATA_SFX_START_8bit_KungFu_Hit,
   NULL,
};


I was close; needed the extra *. G' job on getting it to work.