一个简短的解释,我想要做什么:我想要构建由结构表示的数据元素的分层树。这些元素应该双重链接,这样我才能走路。我不想使用动态分配,因为树的结构在运行时不会改变。指向指向结构体的指针数组的指针数组有什么问题?
struct menu {
uint8_t type; // typ des Menüpunkts
struct menu * parent; // Pointer auf den übergeordneten MP
struct menu *(*children)[]; // Pointer auf untergeordnete MP
};
struct menu *(*menll[5])[]; // auxillary array
struct menu gl_menlist[5]=
{
{0,0,menll[0]},
{0,0,menll[1]},
{0,0,menll[2]},
{0,0,menll[3]},
{0,0,menll[4]}
};
struct menu * rxakvt01[]= {&gl_menlist[3], &gl_menlist[4]};
menll[0]=&rxakvt01;
代码在最后一行失败,此错误消息:
In file included from Dis0_10.ino:6: var/folders/jl/nv1qvh6n569cxq9xxfd6dx980000gn/T/build753942546562757431.tmp/initialisation.h:71: error: expected constructor, destructor, or type conversion before '=' token
后移动VARS和阵列的initialisations到一个功能码,我有一个新的错误消息;有意义得多,但:
/[path_truncated]/initialisation.cpp: In function 'void shit()':
/[path_truncated]/initialisation.cpp:46: error: cannot convert 'menu* (*)[2]' to 'menu* (*)[]' in assignment
这是我见过的第一个C编译器错误引用构造函数和析构函数。当然,这不是C++? – abligh 2014-10-10 18:30:57
那是什么:'struct menu *(* menll [5])[];'? – 2501 2014-10-10 18:34:54
它是一个C++编译器。不幸的是我无法改变它。最后一次我问了一个类似的问题,我用C++标记了它,然后我在C++标签下寻找c解决方案。 – Ariser 2014-10-10 18:35:25