I have a lot of simple (that is, non-structured) typedefs where each is derived ultimately from a built-in type, but with a kind of specialization reminiscent of inheritance in object-oriented languages:
For example (not one I really use), this one makes it easy to declare unsigned int-sized variables or structure fields that will display as hex in the Template Results.
typedef unsigned int hexUint <format=hex>;
A simplification of one’ve tried:
typedef byte bool < read=boolAsString >;
string boolAsString( bool &b )
{
if ( b == 0 ) return "false";
if ( b == 1) return "true";
return Str( "0x%02X", b );
}
Since I have a good number of such definitions, it’s convenient to place them in an “include” file for easy re-use.
However, this doesn’t work well if I include that file in a template for a specific kind of file, and also in a script for that type of file, and run them against the same file.
(I’m running short of time and will add or improve my example later, if you can’t already explain why this might not work, or can’t reproduce it.)