I have this code snippet here:
#define byte uint8_t
byte pins0[11] = { 0, 1, 2, 3, 4, 5, 6, 7, 63, 64, 65};
byte pins1[11] = { 8, 9, 10, 11, 12, 13, 14, 15, 60, 61, 62};
byte pins2[11] = { 16, 17, 18, 19, 20, 21, 22, 15, 60, 61, 62};
byte pins3[11] = { 23, 24, 25, 26, 27, 28, 29, 30, 60, 61, 62};
byte pins4[11] = { 31, 32, 33, 34, 35, 36, 37, 38, 60, 61, 62};
byte pins5[11] = { 39, 40, 41, 42, 43, 44, 45, 46, 60, 61, 62};
byte *segPins[6] = {&pins0,&pins1,&pins2,&pins3,&pins4,&pins5};
The compiler shows an error:
src\main.cpp:15:63: error: cannot convert 'byte (*)[11] {aka unsigned char (*)[11]}' to 'byte* {aka unsigned char*}' in initialization
byte *segPins[11] = {&pins0,&pins1,&pins2,&pins3,&pins4,&pins5};
^
src\main.cpp:15:63: error: cannot convert 'byte (*)[11] {aka unsigned char (*)[11]}' to 'byte* {aka unsigned char*}' in initialization
src\main.cpp:15:63: error: cannot convert 'byte (*)[11] {aka unsigned char (*)[11]}' to 'byte* {aka unsigned char*}' in initialization
src\main.cpp:15:63: error: cannot convert 'byte (*)[11] {aka unsigned char (*)[11]}' to 'byte* {aka unsigned char*}' in initialization
src\main.cpp:15:63: error: cannot convert 'byte (*)[11] {aka unsigned char (*)[11]}' to 'byte* {aka unsigned char*}' in initialization
src\main.cpp:15:63: error: cannot convert 'byte (*)[11] {aka unsigned char (*)[11]}' to 'byte* {aka unsigned char*}' in initialization
*** [.pio\build\nanoatmega328\src\main.cpp.o] Error 1
In my opinion, segPins is an Array of byte pointers. So it should pass the compiler but it sees a difference?
byte *segPins[11]this way ?byte *segPins[6] = {pins0,pins1,...};&pins0 is a address of the pointer which is pointing on array of 11 elements and can be bind tobyte**ptr = &pins0. PS: Note I'm talking now about the case when array decay to pointer but u should understand general situation)byte (*segPins[6])[11]; However, brj's answer is simpler and more typically how this should be done.type-aliasis safer.using byte = uint8_t;ortypedef.