This post is a follow-up to my earlier post about sharing typedefs between templates and scripts.
The template and script provided below are minimized reproducers which
illustrate the subject of this post.
// File: test.bt
#define ATTR read
#define VAL testStr
typedef char myType <ATTR=VAL>;
myType b;
// The function below is needed when ATTR is "read" and VAL is "myTypeStr"
// Apart from having to exist, what it does isn't important.
string testStr( myType &b )
{
return (b != false) ? "true" : "false"
}
// File: test.1sc
RunTemplate( "test.bt", true );
#define ATTR read
#define VAL testStr
typedef char myType <ATTR=VAL>;
myType b;
// The function below is needed when ATTR is "read" and VAL is "myTypeStr"
// Apart from having to exist, what it does isn't important.
string testStr( myType &b )
{
return (b != false) ? "true" : "false"
}
Run test.1sc
once, selecting some arbitrary unimportant file as the data file.
It runs without error.
Now, without clearing the Template Results window, run the script again.
I get the error:
*ERROR Line
n: Redefinition of typedef did not match earlier typedef.
However, if first you do clear the Template Results window, no error occurs.
- The typedef is exactly the same in the template and the script.
- If the definition of ATTR is changed to to
comment
orname
, there is no error.
At the time of posting I’m on a system lacking 010 Editor, so what’s above is a transcription and might not be error-free.
If they don’t actually do what I claim, I’ll fix them later.