Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Interace property's case changed when viewed/used in tlb and c++ c

25 views
Skip to first unread message

Cam

unread,
Jan 19, 2005, 7:01:04 PM1/19/05
to
I have an interface defined (see below) that has a get and put property
called 'Quantity'. When I attempt to view this property by opening the type
library in the OLE/COM Object viewer the property now has a lowercase 'q' and
it is now 'quantity'. The same problem occurs when attempting to use the
property from a smart pointer (ISeriesDefinitionPtr) in my c++ code: I get a
C2039 compiler error from Visual Studio 2003, stating that 'Quantity' is not
a member of ISeriesDefinition. If I replace 'Quantity' with 'quantity' then
the code complies successfully.

Does anybody know how to make sure the case doesn't change (regardless of
the method)?

[
object,
uuid(<snip>),
dual,
nonextensible,
pointer_default(unique),
helpstring("Series Definition object.")
]
interface ISeriesDefinition : IPackageDefinition
{
<snip>
[id(202), propget, helpstring("Quantity.")]
HRESULT Quantity([out, retval] int *quantity);

[id(202), propput, helpstring("Quantity.")]
HRESULT Quantity([in] int quantity);
<snip>
]

Igor Tandetnik

unread,
Jan 19, 2005, 7:12:23 PM1/19/05
to
"Cam" <C...@discussions.microsoft.com> wrote in message
news:F0C6FB4B-6A5D-4C54...@microsoft.com

> I have an interface defined (see below) that has a get and put
> property called 'Quantity'. When I attempt to view this property by
> opening the type library in the OLE/COM Object viewer the property
> now has a lowercase 'q' and it is now 'quantity'.

For technical reasons, TLB file format is physically incapable of
storing two strings that differ only in case. So when there are
conflicts, MIDL compiler has no choice but to pick one capitalization
variant and stick with it throughout.

So, avoid using strings in your IDL that differ only in case - just give
some other name to the parameter.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


Cam

unread,
Jan 19, 2005, 8:17:01 PM1/19/05
to
Igor,

Are you saying that you can't have two interfaces in the same tlb with the
same property?

Cam

Cam

unread,
Jan 19, 2005, 8:59:01 PM1/19/05
to
Just to clarify my original post:
My ISeriesDefinition's get property 'Quantity' is the same character case as
the put property 'Quantity' and there are NO properties in the
ISeriesDefinition interface with the name 'quantity' (lowercase q).

Craig Kelly

unread,
Jan 19, 2005, 10:38:46 PM1/19/05
to
"Cam" wrote:
> Igor,
>
> Are you saying that you can't have two interfaces in the same tlb with the
> same property?
>

<snip>

Cam,

No, he's saying that when MIDL sees:

HRESULT Quantity([out, retval] int *quantity);

It will only store the string "Quantity" (the prop name) or the string
"quantity" (the argument name). Your prop name is losing the battle. To
fix your problem, you could use

HRESULT Quantity([out, retval] int *qty);

Craig


Walters@discussions.microsoft.com Michael Walters

unread,
Jan 23, 2005, 5:13:01 PM1/23/05
to
All,

I have recently tested it and the issue exists with any string in the TLB
file. Each string is stored once regardless of which interface contains it.
Thus if you have two interfaces that share a string (either as a parameter or
property) they will all share the same capitilazation (Seemingly chosen from
the first encountered string).

I don't know, or care, if this is the way it is intended; however this is
the way I found it to be.

Igor Tandetnik

unread,
Jan 24, 2005, 1:30:58 PM1/24/05
to
"Michael Walters" <Michael Wal...@discussions.microsoft.com> wrote in
message news:90EDEB29-EBC5-4A40...@microsoft.com

> I have recently tested it and the issue exists with any string in the
> TLB file. Each string is stored once regardless of which interface
> contains it. Thus if you have two interfaces that share a string
> (either as a parameter or property) they will all share the same
> capitilazation (Seemingly chosen from the first encountered string).

This is precisely my point. TLB file format stores all strings (method
names, interface names, parameter names - all of them) in a hash table
that is case-insensitive but case-preserving. Meaning that it preserves
the case of the string when it is first added to the table, but ignores
the case when looking for existing entries. So when you add a string
that only differs in case from the existing one, you just get back an
existing entry.

0 new messages