I’d like my structs to be able to reflect the format attribute set when declaring them. For example, something like this:
typedef struct {
int x;
} S <read=ReadS>;
string ReadS(S &s) {
if (GetDisplayFormat() == DISPLAY_FORMAT_HEX) {
return Str("%xh", s.x);
} else {
return Str("%d", s.x);
}
}
S s <format=hex>;
Unfortunately, this doesn’t work because the format attribute doesn’t actually alter the current display format, and I haven’t found any methods to get attribute values. Is there any other way to check, inherit, etc the attributes of the declaration?
I can accomplish the same thing using a parameter, but I’d prefer to use the standard attribute instead:
typedef struct (int hex) {
local int hex = hex;
int x;
} S <read=ReadS>;
string ReadS(S &s) {
if (s.hex) {
return Str("%xh", s.x);
} else {
return Str("%d", s.x);
}
}
S s(1);
Thank you!