Listing 1: Using a macro to typedef pointers to structures

/* This macro generates an opaque, unique, type whose name is
 * given by the _otype_ parameter.
 */

#define stlsoft_gen_opaque(_otype_) \
 typedef const struct __stlsoft_otype_##_otype_{ int i;} *_otype_;

stlsoft_gen_opaque(MyType1)
stlsoft_gen_opaque(MyType2)

MyType1 mt1 =   0x00000001; // Error
MyType2 mt2 =   reinterpret_cast<MyType2>(0x00000001);

///...

void func(){

if(mt2 & 0x07070707)    // Error
{
//  ...
}

if(mt2 & reinterpret_cast<MyType2>(0x07070707)) // Error
{
//  ...
}

if(reinterpret_cast<unsigned long>(mt2) & 0x07070707)
{
//  ...
}

}