More on ntp_control cleanup

Hal Murray hmurray at megapathdsl.net
Wed Mar 10 12:15:22 UTC 2021


How do I compute at compile time the offset of a field into a struct?

The context is putting it into a table.


I know about structs and unions.  Unions are type-unsafe.  Is there a 
type-safe way to handle a struct that needs several variations?

The struct will have a type field to tell me which variation it is.  I will 
have a macro to build each variation.    There is only one place that looks at 
the variations.  It will do a select on the type field with a few lines of 
code for each variation.  So all in all, it's pretty clean.  I'm just looking 
for a way to do better.



-- 
These are my opinions.  I hate spam.





More information about the devel mailing list