From: Spiro Trikaliotis (Trik-news_at_gmx.de)
Date: 2003-01-23 08:44:25
Hello, Groepaz wrote: > On Wednesday 22 January 2003 23:37, Christian Krüger wrote: > > today I've tried to compile something like this: > > > > --8<------------------- > > > > typedef struct > > { > > unsigned char width; > > unsigned char height; > > unsigned char data[]; > > } > > TestStruct; > > > > --8<------------------- > why dont you simply use > > typedef struct > { > unsigned char width; > unsigned char height; > unsigned char *data; > } > TestStruct; Because it's not the same? ;-) First: Christian, doesn't unsigned char data[0]; work as last element in CC65? If not, use it like David Holtz suggested with index 1. Groepaz: There is a difference. In your code, TestStruct contains a pointer to some area. This is not true with Christian's wanted solution. Look at this: TestStruct *a = malloc(sizeof(TestStruct)+sizeof(unsigned char)*100); With this, you get a TestStruct which contains 100 elements (0..99) [in case the 0 does not work, and David's suggestion has to be applied, it is 101, ie., 0..100]. With your solution, you had to TestStruct *a = malloc(sizeof(TestStruct)); a->data = malloc(sizeof(unsigned char)*100); which is less handy than the first solution. Spiro. ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo_at_musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2003-01-23 08:45:16 CET