The other day, we were writing some .NET code for which we produced COM wrappers,
including a type library (through
tlbexp
). One of the exported methods
looked like this (in Managed C++):
void AddButton(String *title, String *icon, ActionType type);
In a COM test client which referred to said type library, the compiler
reported inexplicable errors. They hinted that the parameter named
(!)
type
somehow was thought to be of type
System.Type...
but why?
type
is correctly declared as an
ActionType
, not as
System::Type
!
I won't tell you what other means we used to track down this issue;
let me just advise you to clean those chicken blood stains as early as
possible, before they stick to your keyboard just like, well, chicken blood .-)
In the end,
Adam Nathan's blue bible had the right hint for us: Type libraries maintain a case-insensitive
identifier table. Once an identifier has been added to the table in one
case, any subsequent attempts to add the identifier to the table again
will simply fail, regardless of the case.
So in our example, the first "type"-ish identifier which was added to the table
was
System::Type
. (Or maybe it was actually a parameter called
type
which
was of type
System::Type
?). Later, the parameter name
type
was encountered,
but no longer added to the table because of its unlikely relative which made it
into the table first. Any subsequent references to anything called "type"
or "Type" or "tYPE" would then resolve to
System::Type
, with the aforementioned
consequences.
to top