Redefinition of ‘BOOKMARK’

If you include in a VC++ project <mapidefs.h> and <sqltypes.h> and build for the x64 platform you get a redefinition error.

1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\sqltypes.h(283) : error C2371: ‘BOOKMARK’ : redefinition; different basic types
1> C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\MAPIDefS.h(1142) : see declaration of ‘BOOKMARK’

The reason is that BOOKMARK is defined in both files.

This is mapidefs.h

This is sqltypes.h

On x86, both ULONG and SQLULEN are an unsigned long. However, on x64, ULONG is still unsigned long, but SQLULEN is an UINT64, which is different than unsigned long. Hence the error.

There is a Connect bug report called Using x64 with mapidefs.h and sqltypes.h causes C2371 filed by Martin Richter 6 years ago (!), with no fix yet. Martin proposed the following workaround:

However, it doesn’t work for me. I get the very same error. To get rid of the error you have to use namespaces. Define two namespaces, let’s call them MAPI and SQL and include each header in one of them. Then you can use the using namespace directive so that you don’t have to prefix everything with MAPI:: or SQL::. However, you’ll have to use the fully qualified name when you want to use one or the other BOOKMARK, as shown in the following example:

, , , , Hits for this post: 49146 .