Arrays of pointers to arrays?

Posted by a2h on Stack Overflow See other posts from Stack Overflow or by a2h
Published on 2010-05-04T08:51:03Z Indexed on 2010/05/04 8:58 UTC
Read the original article Hit count: 331

Filed under:
|
|

I'm using a library which for one certain feature involves variables like so:

extern const u8 foo[];
extern const u8 bar[];

I am not allowed to rename these variables in any way.

However, I like to be able to access these variables through an array (or other similar method) so that I do not need to continually hardcode new instances of these variables into my main code.

My first attempt at creating an array is as follows:

const u8* pl[] = {
    &foo,
    &bar
};

This gave me the error cannot convert 'const u8 (*)[]' to 'const u8*' in initialization, and with help elsewhere along with some Googling, I changed my array to this:

u8 (*pl)[] = {
    &foo,
    &bar
};

Upon compiling I now get the error scalar object 'pl' requires one element in initializer.

Does anyone have any ideas on what I'm doing wrong? Thanks.

© Stack Overflow or respective owner

Related posts about c++

Related posts about pointers