Get aliased type
Steven Schveighoffer
schveiguy at yahoo.com
Tue Jan 2 16:31:28 UTC 2018
On 1/2/18 7:45 AM, John Chapman wrote:
> On Tuesday, 2 January 2018 at 12:19:19 UTC, David Nadlinger wrote:
>> There is indeed no way to do this; as you say, aliases are just names
>> for a particular reference to a symbol. Perhaps you don't actually
>> need the names in your use case, though?
>>
>> — David
>
> The idea was to distinguish between a BSTR (an alias for wchar* from
> core.sys.windows.wtypes used widely with COM) and wchar* itself, chiefly
> so that I could call the appropriate Windows SDK functions on them to
> convert them to and from D strings. Although BSTRs look like wchar*s to
> the end user they are not really interchangable - for example, calling
> SysFreeString on a regular wchar* will cause a crash.
>
> According to the docs, a BSTR is prefixed with its length and ends in a
> null character, but I'm not sure if checking for the existence of those
> is going to be good enough
Hm... perhaps the correct path is to define a BSTR as a struct with a
wchar in it. I wouldn't even use Typedef since they aren't the same
thing (one doesn't convert to the other).
But I don't know how that would affect existing code.
-Steve
More information about the Digitalmars-d-learn
mailing list