我在这里有此代码段:
#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};
编译器显示错误:
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
我认为segPins
是byte
指针的数组。因此它应该通过编译器,但有区别吗?
答案 0 :(得分:2)
您需要的是
byte *segPins[6] = {pins0,pins1,pins2,pins3,pins4,pins5};
这是因为&pins0
指向数组pins0
的地址。
有关更多信息,请参见this问题的答案。