Christophe Ortiz <[email protected]> writes: > I am not sure to understand what you mean. What do you mean by modules able > to register additional variables ?
It depends on the scope of your code. If you are solving only one problem, then you're probably happy to define a struct somewhere that your entire code can see it and place your fields in there. In that case, you can use the offsetof() macro to do stable indexing within the struct (so that you can add or reorder fields later without needing to change code like matrix assembly). Other projects are more like frameworks where users want to write libraries of material models, process parametrizations, and the like. If you had a single global struct, then everyone would be changing things and you give up the ability to change the fields at run-time, meaning that you'll have a soup of #ifdefs and in general, the struct becomes a constant source of problems. So you wouldn't want that. A better approach is to have a dynamic registration system where you declare dependencies and access fields through an interface.
pgpuNMI8TDFPv.pgp
Description: PGP signature
