4 ms·
Something similar, yes. Behind the scenes, datatype99 deduces a type of a matched expression using the typedefs generated earlier.
by Hirrolot 6y ago
Something similar, yes. Behind the scenes, datatype99 deduces a type of a matched expression using the typedefs generated earlier.
- marcodiego 6y agoYou mean, type_id and type_name would have to be handwritten functions, right? If it is possible to automatically generate these, could you provide an example?
- Hirrolot 6y agoWe can generate a type ID by defining an extern variable of a sum type inside the `datatype` macro. Its address then will be a type ID (though I am not sure that such two variables will always have different addresses, I need to check the standard). About type_name: you can deduce a type name if you know at least one tag of a sum type. For example, if a tag is `Foo`, then `FooSumT` is a typedef to an outer sum type (datatype99 generates this typedef).
- eqvinox 6y agoTwo non-const variables will always have different addresses if they are of the same type. Different types can [AFAIR] per the standard theoretically be in different address spaces, though this is rare in practice.
- a1369209993 6y ago> Different types can [AFAIR] per the standard theoretically be in different address spaces If you can force the types to contain a member of the same type (say, a int or enum foobar_discriminant), the pointers &const_var_foo.disc and &const_var_bar.disc would have to differ for obvious reasons.