Microsoft Knowledge Base Email Alertz

KBAlertz.com: (192561) - When building a project with ATL 3.0 you may get a compiler error c2787 (no GUID has been associated with this object).

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 192561 - Last Review: December 10, 2003 - Revision: 2.0

PRB: Error C2787 When Building a Project Using ATL 3.0

This article was previously published under Q192561

On This Page

SYMPTOMS

When building a project with ATL 3.0 you may get a compiler error c2787 (no GUID has been associated with this object).

CAUSE

The newer versions of MIDL use the compiler facility [__declspec(uuid())] to tag a GUID to an interface in the header files it generates. ATL version 3.0 makes use of this fact in the implementation of COM_INTERFACE_ENRY macro; it now uses the keyword __uuidof() to extract the interface ID from the MIDL-generated header. ATL 2.1 uses the token pasting operator (IID_##IFoo) to get the interface ID. This action requires including the MIDL-generated header and also the "project_i.c", which MIDL generated.

If you use an older MIDL-generated header file [which does not use __declspec(uuid())] with ATL 3.0, you will get this compiler error, because __uudiof() can't extract the interface ID.

RESOLUTION

Define the preprocessor symbol _ATL_NO_UUIDOF in the C/C++ tab of the Project Settings dialog box. This forces ATL to use the token pasting operator (##) rather than __uuidof() when forming the interface ID.

STATUS

This behavior is by design.

MORE INFORMATION

Sample Code

   COM_INTERFACE_ENTRY in ATL 2.1
   
      #define COM_INTERFACE_ENTRY(x)\ 
         {&IID_##x), \ 
         offsetofclass(x, _ComMapClass), \ 
         _ATL_SIMPLEMAPENTRY},
   
   COM_INTERFACE_ENTRY in ATL 3.0
   
      #ifndef _ATL_NO_UUIDOF
      #define _ATL_IIDOF(x) __uuidof(x)
      #else
      #define _ATL_IIDOF(x) IID_##x
      #endif
   
      #define COM_INTERFACE_ENTRY(x)\ 
         {&_ATL_IIDOF(x), \ 
         offsetofclass(x, _ComMapClass), \ 
         _ATL_SIMPLEMAPENTRY},
				
Newer MIDL headers files use the macros DECLSPEC_UUID() or MIDL_INTERFACE(), which expand to __declspec(uuid()). MIDL versions 3.01.75 and later use the __declspec directive.

REFERENCES

"Porting from ATL 2.1" in the online help.

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Jaganathan Thangavelu, Microsoft Corporation.

APPLIES TO
  • Microsoft ActiveX Template Library 3.0, when used with:
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
Keywords: 
kbprb kbmidl KB192561
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please