IDL Help  
Author Message
GIJimmyj





PostPosted: Wed Jul 20 10:57:32 CDT 2005 Top

Visual Studio C++ >> IDL Help

Newbie question:

What is the syntax to declare a string constant in an IDL? I'm trying to
compile a type lib that I can reference and use from VB project.

If I use 'string', I get an error:
"syntax error : expecting a type specification or a storage specifer or a
type qualifier near "string"

If I use 'BSTR', I get an error:
error C2440: 'initializing' : cannot convert from 'char [24]' to 'unsigned
short *const '

If I use 'wchar_t *' I can compile it, but obviously I cannot use it in VB.

TIA.

Visual Studio128  
 
 
Kerem





PostPosted: Wed Jul 20 10:57:32 CDT 2005 Top

Visual Studio C++ >> IDL Help http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcattrib/html/vcrefstring.asp

Best Regards

Kerem Gümrükcü


 
 
SteveK





PostPosted: Thu Jul 21 09:42:02 CDT 2005 Top

Visual Studio C++ >> IDL Help I guess I finally figured out the answer, if anyone's interested. String
constants declared this way can be used in VB.

[string] BSTR const MyConst = L"My Const";



> Newbie question:
>
> What is the syntax to declare a string constant in an IDL? I'm trying to
> compile a type lib that I can reference and use from VB project.
>
> If I use 'string', I get an error:
> "syntax error : expecting a type specification or a storage specifer or a
> type qualifier near "string"
>
> If I use 'BSTR', I get an error:
> error C2440: 'initializing' : cannot convert from 'char [24]' to 'unsigned
> short *const '
>
> If I use 'wchar_t *' I can compile it, but obviously I cannot use it in VB.
>
> TIA.
>