Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Header Generation    [ Add a report in this area ]  
Report #:  71288   Status: Open
The compiler should explicitly qualify interfaces in type conversion operators
Project:  C++Builder Build #:  3210
Version:    12.1 Submitted By:   Moritz Beutel
Report Type:  Basic functionality failure Date Reported:  2/9/2009 3:01:59 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   268017
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
Currently, code like
// -----
uses
  msxml;
type
  TMyDispatch = class (TInterfacedObject, IDispatch)
    ...
  end;
    TMyXMLDocument2 = class (TInterfacedObject, IXMLDocument2)
    ...
  end;
// -----

emits this to the header file:
// -----
class PASCALIMPLEMENTATION TMyDispatch : public System::TInterfacedObject
{

...
public:

#if defined(MANAGED_INTERFACE_OPERATORS)

...

#else

operator IDispatch*(void) { return (IDispatch*)&__IDispatch; }

#endif
};
class PASCALIMPLEMENTATION TMyXMLDocument2 : public System::TInterfacedObject
{

...
public:

#if defined(MANAGED_INTERFACE_OPERATORS)

...

#else

operator IXMLDocument2*(void) { return (IXMLDocument2*)&__IXMLDocument2; }

#endif

};
// -----

No namespace qualifier is added, regardless of whether the symbol is declared as $EXTERNALSYM (as IDispatch is) or not. This is prone to ambiguities.

I suggest that the compiler emits ::-prefixed names for $EXTERNALSYM'ed types and full namespace qualifiers otherwise:

// -----

operator ::IDispatch*(void) { return (::IDispatch*)&__IDispatch; }

#endif
...

operator Msxml::IXMLDocument2*(void) { return (Msxml::IXMLDocument2*)&__IXMLDocument2; }
// -----
Steps to Reproduce:
- Create a new .cpp file with this content (or download the attachment):

// -----
#include <vcl.h>
#include <ScrptMgr.hpp>
#include <tchar.h>
#pragma hdrstop

int _tmain (void)
{
    return 0;
}
// -----

- Try to compile it (bcc32 -WCV qc71288.cpp)

Exp.: compiles
Act.: E2015 Ambiguity between 'IXMLDocument' and 'Midcomp::IXMLDocument'
Workarounds
None
Attachment
qc71288.zip
Comments

None

Server Response from: ETNACODE01