Am 22.12.2011 20:57, schrieb Anthony Liguori: > On 12/22/2011 12:00 PM, Kevin O'Connor wrote: >> On Thu, Dec 22, 2011 at 11:41:08AM -0600, Anthony Liguori wrote: >>> On 12/22/2011 11:25 AM, Kevin O'Connor wrote: >>>> Why not declare types with something like the following: >>>> >>>> TypeInfo my_device_info = { >>>> .name = "my-device", >>>> .parentinfo =&device_info, >>>> .instance_size = sizeof(MyDevice), >>>> }; >>>> >>>> That is, instead of looking up the TypeImpl via a string, lookup the >>>> TypeImpl via the address of the TypeInfo. (Or possibly store a >>>> pointer to TypeImpl in TypeInfo during registration.) [...] > Yes, thinking about it, I think you're correct that .parent could refer > to some sort of type handle. > > But I think it's a bit nicer to have a string identify the parent type > than an extern struct. I guess it's more a matter of taste than > anything else :-)
The advantage of using some kind of symbolic name is that the compiler helps us avoid typos. If we use strings, we defer the checking to the actual instantiation at runtime. Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg