Hi , While trying to port to Codewarrior environment, i find that the below type of structure declaration is supported only in cygwin/gcc but not in Codewarrior. It breaks in codewarrior environment. Has anyone come across such a thing and could someone here tell me an equivalent alternative for this so that i can use in codewarrior environment. struct tfsdev alt_tfsdevtbl[TFSDEVTOT] = { [0 ... (TFSDEVTOT-1)] = { (char *)0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff } }; char alt_devnames[TFSDEVTOT][TFSNAMESIZE] = { [0 ... (TFSDEVTOT-1)] = { [0 ... (TFSNAMESIZE-1)] = 0xff } }; Regards, Karthik Balaguru
structure declaration not supported
Started by ●November 9, 2006
Reply by ●November 9, 20062006-11-09
karthikbg wrote:> Hi , > > While trying to port to Codewarrior environment, i find that the below > type of structure declaration is supported only in cygwin/gcc but not > in Codewarrior. It breaks in codewarrior environment. > > Has anyone come across such a thing and could someone here tell me an > equivalent alternative for > this so that i can use in codewarrior environment. > > struct tfsdev alt_tfsdevtbl[TFSDEVTOT] = { > [0 ... (TFSDEVTOT-1)] = > { (char *)0xffffffff, 0xffffffff, 0xffffffff, > 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff } > }; > > char alt_devnames[TFSDEVTOT][TFSNAMESIZE] = { > [0 ... (TFSDEVTOT-1)] = > { [0 ... (TFSNAMESIZE-1)] = > 0xff } > };Inititalize the struct in a loop. for(p= (char *) alt_tfsdevtbl,i = 0; i < sizeof(alt_tfsdevtbl); i ++) { *p++ = 0xff; }> > Regards, > Karthik Balaguru-- Best Regards, Ulf Samuelsson ulf@a-t-m-e-l.com This message is intended to be my own personal view and it may or may not be shared by my employer Atmel Nordic AB
Reply by ●November 9, 20062006-11-09
Hi, There is NO direct replacement in Codewarrior for the structure declaration you are referring to. Although I am not familiar with the Cygwin/gcc compiler you mention, the declaration: struct tfsdev alt_tfsdevtbl [TFSDEVTOT] = { [0 ... (TFSDEVTOT-1)] = { (char *)0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff } }; is basically telling the compiler to statically initialize all elements in alt_tfsdevtbl (from 0 to (TFSDEVTOT-1)) to the defaults: { (char *)0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff } (If I am correct, that means that the tfsdev structure contains 7 "elements/fields"). To make a similar declaration in Codewarrior you must do the following: struct tfsdev alt_tfsdevtbl [TFSDEVTOT] = { { (char *)0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }, //0 { (char *)0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }, //1 { (char *)0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }, //2 ... { (char *)0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }, // TFSDEVTOT-2 { (char *)0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }, // TFSDEVTOT-1 }; If TFSDEVTOT is too big, try to encapsulate the initialization in a function: for ( i = 0; i < TFSDEVTOT; i++ ) { alt_tfsdevtbl [i].xxxxxxx = 0xffffffff; alt_tfsdevtbl [i].xxxxxxx = 0xffffffff; ... OR memset ( &alt_tfsdevtbl[i], 0xFF, sizeof ( struct tfsdevtbl )); } Regards Rene Trenado to karthikbg wrote:> Hi , > > While trying to port to Codewarrior environment, i find that the below > type of structure declaration is supported only in cygwin/gcc but not > in Codewarrior. It breaks in codewarrior environment. > > Has anyone come across such a thing and could someone here tell me an > equivalent alternative for > this so that i can use in codewarrior environment. > > struct tfsdev alt_tfsdevtbl[TFSDEVTOT] = { > [0 ... (TFSDEVTOT-1)] = > { (char *)0xffffffff, 0xffffffff, 0xffffffff, > 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff } > }; > > char alt_devnames[TFSDEVTOT][TFSNAMESIZE] = { > [0 ... (TFSDEVTOT-1)] = > { [0 ... (TFSNAMESIZE-1)] = > 0xff } > }; > > Regards, > Karthik Balaguru
Reply by ●November 9, 20062006-11-09
Reply by ●November 9, 20062006-11-09
karthikbg wrote:> Hi , > > While trying to port to Codewarrior environment, i find that the below > type of structure declaration is supported only in cygwin/gcc but not > in Codewarrior. It breaks in codewarrior environment. > > Has anyone come across such a thing and could someone here tell me an > equivalent alternative for > this so that i can use in codewarrior environment. > > struct tfsdev alt_tfsdevtbl[TFSDEVTOT] = { > [0 ... (TFSDEVTOT-1)] = > { (char *)0xffffffff, 0xffffffff, 0xffffffff, > 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff } > }; > > char alt_devnames[TFSDEVTOT][TFSNAMESIZE] = { > [0 ... (TFSDEVTOT-1)] = > { [0 ... (TFSNAMESIZE-1)] = > 0xff } > }; > > Regards, > Karthik BalaguruIf you read the GCC manual, you'll note that the construct you're using is a GCC extension. Cygwin has nothing to do with this feature. -- Tauno Voipio tauno voipio (at) iki fi
Reply by ●November 10, 20062006-11-10
Tauno Voipio wrote:> karthikbg wrote: > > Hi , > > > > While trying to port to Codewarrior environment, i find that the below > > type of structure declaration is supported only in cygwin/gcc but not > > in Codewarrior. It breaks in codewarrior environment. > > > > Has anyone come across such a thing and could someone here tell me an > > equivalent alternative for > > this so that i can use in codewarrior environment. > > > > struct tfsdev alt_tfsdevtbl[TFSDEVTOT] = { > > [0 ... (TFSDEVTOT-1)] = > > { (char *)0xffffffff, 0xffffffff, 0xffffffff, > > 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff } > > }; > > > > char alt_devnames[TFSDEVTOT][TFSNAMESIZE] = { > > [0 ... (TFSDEVTOT-1)] = > > { [0 ... (TFSNAMESIZE-1)] = > > 0xff } > > }; > > > > Regards, > > Karthik Balaguru > > > If you read the GCC manual, you'll note that the construct > you're using is a GCC extension. Cygwin has nothing to do > with this feature. > > -- > > Tauno Voipio > tauno voipio (at) iki fiYes, It should be GCC only. (Cygwin is the environment. Sorry, I should have mentioned clearly). Regards, Karthik Balaguru