static array of structures
    Ben Gardner 
    bengardner.uncrustify at gmail.com
       
    Fri Mar 31 13:42:38 PST 2006
    
    
  
Hi,
I'm trying to convert some C code to D, but I ran into a little problem.
The C code defines a fairly large static array of structures.
At run time, the table is scanned to find a matching string.
Below is how I think the array of structures should be written in d.
I didn't post the C code because it is nearly identical.
struct options_table
{
   option_id id;
   char []   name;
   argtype_t type;
};
options_table [] the_table =
{
   { UO_option1, "option1", AT_NUM },
   { UO_option2, "option2", AT_STRING },
   { UO_option3, "option3", AT_BOOL },
};
However, this gives me the error:
Error: a struct is not a valid initializer for a options_table []
I assume there is a simple way to do this.
Thanks in advance for any help!
Ben
    
    
More information about the Digitalmars-d-learn
mailing list