In older Borland/Embarcadero compilers there was a compiler bug which was occasionally causing this. However I found an workaround:
which among other things also allows to use the assignment like you want again... However I doubt its still the case with newer compilers but still worth trying.
If that does not work There is still one option I used before I found this workaround. You have to create loading function that returns your struct
(something like constructor) and then just feed array with it...
Here 2 options (Both working on my BDS2006 C++ and also both can be combined together):
//---------------------------------------------------------------------------
// I assume your VCL form components ...
TLabel *LabelP1; TShape *Led1P1,*Led2P1,*Led3P1,*Led4P1,*Led5P1,*Led6P1,*Led7P1,*Led8P1,*Led9P1,*Led10P1;
TLabel *LabelP2; TShape *Led1P2,*Led2P2,*Led3P2,*Led4P2,*Led5P2,*Led6P2,*Led7P2,*Led8P2,*Led9P2,*Led10P2;
TLabel *LabelP3; TShape *Led1P3,*Led2P3,*Led3P3,*Led4P3,*Led5P3,*Led6P3,*Led7P3,*Led8P3,*Led9P3,*Led10P3;
TLabel *LabelP4; TShape *Led1P4,*Led2P4,*Led3P4,*Led4P4,*Led5P4,*Led6P4,*Led7P4,*Led8P4,*Led9P4,*Led10P4;
TLabel *LabelP5; TShape *Led1P5,*Led2P5,*Led3P5,*Led4P5,*Led5P5,*Led6P5,*Led7P5,*Led8P5,*Led9P5,*Led10P5;
// struct
struct pannello_t
{
String nome;
TLabel* labelNome;
TShape* ShapeLed[10];
};
// load function for style 2
pannello_t ld(String nome,TLabel* labelNome,TShape* S0,TShape* S1,TShape* S2,TShape* S3,TShape* S4,TShape* S5,TShape* S6,TShape* S7,TShape* S8,TShape* S9)
{
pannello_t a;
a.nome=nome;
a.labelNome=labelNome;
a.ShapeLed[0]=S0;
a.ShapeLed[1]=S1;
a.ShapeLed[2]=S2;
a.ShapeLed[3]=S3;
a.ShapeLed[4]=S4;
a.ShapeLed[5]=S5;
a.ShapeLed[6]=S6;
a.ShapeLed[7]=S7;
a.ShapeLed[8]=S8;
a.ShapeLed[9]=S9;
return a;
}
//---------------------------------------------------------------------------
void test()
{
// 1. style
pannello_t A[5]=
{
{"HCL-XXX", LabelP1, {Led1P1, Led2P1, Led3P1, Led4P1, Led5P1, Led6P1, Led7P1, Led8P1, Led9P1, Led10P1} },
{"HCL-XXX", LabelP2, {Led1P2, Led2P2, Led3P2, Led4P2, Led5P2, Led6P2, Led7P2, Led8P2, Led9P2, Led10P2} },
{"HCL-XXX", LabelP3, {Led1P3, Led2P3, Led3P3, Led4P3, Led5P3, Led6P3, Led7P3, Led8P3, Led9P3, Led10P3} },
{"HCL-XXX", LabelP4, {Led1P4, Led2P4, Led3P4, Led4P4, Led5P4, Led6P4, Led7P4, Led8P4, Led9P4, Led10P4} },
{"HCL-XXX", LabelP5, {Led1P5, Led2P5, Led3P5, Led4P5, Led5P5, Led6P5, Led7P5, Led8P5, Led9P5, Led10P5} },
};
// 2. style
pannello_t B[5];
B[0]=ld("HCL-XXX", LabelP1, Led1P1, Led2P1, Led3P1, Led4P1, Led5P1, Led6P1, Led7P1, Led8P1, Led9P1, Led10P1 );
B[1]=ld("HCL-XXX", LabelP2, Led1P2, Led2P2, Led3P2, Led4P2, Led5P2, Led6P2, Led7P2, Led8P2, Led9P2, Led10P2 );
B[2]=ld("HCL-XXX", LabelP3, Led1P3, Led2P3, Led3P3, Led4P3, Led5P3, Led6P3, Led7P3, Led8P3, Led9P3, Led10P3 );
B[3]=ld("HCL-XXX", LabelP4, Led1P4, Led2P4, Led3P4, Led4P4, Led5P4, Led6P4, Led7P4, Led8P4, Led9P4, Led10P4 );
B[4]=ld("HCL-XXX", LabelP5, Led1P5, Led2P5, Led3P5, Led4P5, Led5P5, Led6P5, Led7P5, Led8P5, Led9P5, Led10P5 );
}
//---------------------------------------------------------------------------
Beware that if you are using the definition inside declaration of your array then the VCL components you are assigning must be already pointing to your created VCL components. If you can not guarantee it then the only safe options are either feed the array in runtime using style 2 and ld
function for example in Form constructor or instead of just pointers use pointer of pointer...
Also I saw that some compilers have problems with using struct (not Borland however) in such cases using typedef helps...
typedef struct
{
String nome;
TLabel* labelNome;
TShape* ShapeLed[10];
} pannello_t;