Microsoft KB Archive/185284

= FIX: #import Does not Correctly Handle GUID Parameters =

Article ID: 185284

Article Last Modified on 10/24/2003

-

APPLIES TO


 * Microsoft Visual C++ 5.0 Enterprise Edition
 * Microsoft Visual C++ 5.0 Professional Edition

-



This article was previously published under Q185284



SYMPTOMS
When using the #import directive on a type library with a method containing a GUID as a parameter, or methods containing a structure that contains a GUID as a parameter, you might encounter one of the following error messages:

C2664: 'Method1' : cannot convert parameter 1 from 'struct _GUID *' to 'struct GUID *'

C2664: 'raw_Method2' : cannot convert parameter 1 from 'struct GUID' to 'struct GUID'

C2079: 'm_guid' uses undefined struct 'GUID'

You might also encounter one of these error messages when you use parameters of type IID, CLSID, FMTID, UUID, CATID, and references to these types (REFGUID, REFIID, etc.).



CAUSE
The #import statement incorrectly interprets struct _GUID as struct GUID. GUID is only a typedef for struct _GUID.



RESOLUTION
Use the "rename" attribute with #import to replace the string GUID with _GUID. For example: #import "myproject.tlb" rename("GUID", "_GUID")



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been corrected in Microsoft Visual C++, version 6.0.

