Using of #pragma in IDL files
Using #pragma vbname
With #pragma vbname you can map an IDL name to
any VB name you want. See the following examples.
The reason why #pragma vbname exists
It is not possible to compile VB programs to executable files
if project name plus class name has more than 39 characters
due to a limitation of VB5 and ActiveX. Please use
the #pragma vbname in your IDL files to work around.
Example of using #pragma vbname
module CosNaming
{
#pragma vbname CosNaming
// A good method to shorten VB names is setting a module name to nothing.
// Above #pragma sets the module name CosNaming to nothing
interface NamingContext
{ // VB name of this interface will be c_NamingContext
// Without #pragma the VB name would be c_CosNamingNamingContext
};
};
Example of using #pragma together with __IDL2VB__ macro
module CosNaming
{
// If you have problems using #pragma with other IDL compilers
// but the preprocessor works fine so you can write following
#if defined __IDL2VB__
#pragma vbname CosNaming
#endif
interface NamingContext
{ // VB name of this interface will be c_NamingContext
};
};
Example of shortening an interface name
module grid
{
interface MyServer
{ // interface name will be c_gridMySrv
};
// Map the interface name MyServer to MySrv
#pragma vbname MyServer MySrv
};
Example of setting a name of an anonymous sequence
module grid
{
typedef sequence<sequence<long> > Fred;
// Map anonymous sequence of long to SeqOfLng
#pragma vbname sequence<long> SeqOfLng
};
Using #pragma vbclsprefix
With #pragma vbclsprefix you can set the prefix of all
generated VB classes. The default prefix is c_. This default can be
overwritten by compiler option -C.
Example of setting VB class prefix
// Set the VB class prefix to cIdl
#pragma vbclsprefix cIdl
module grid
{
interface MyServer
{ // VB class name of this interface will be cIdlgridMyServer.cls
// Without #pragma the VB name would be c_gridMyServer.cls
};
};
Using #pragma vbmodprefix
With #pragma vbmodprefix you can set the prefix of all
generated VB modules. The default prefix is m_. This default can be
overwritten by compiler option -M.
Example of setting VB module prefix
// Set the VB module prefix to mIdl
#pragma vbmodprefix mIdl
module grid
{
interface MyServer
{ // VB module name of this interface will be mIdlgridMyServer.bas
// Without #pragma the VB name would be m_gridMyServer.bas
};
};