Bad compiler error message. 
Author Message
 Bad compiler error message.

If you try to construct an object from an external assembly with only
internal constructors, you get the error message C2512: "no appropriate
default constructor available".  I have found this very confusing since the
constructor I was trying to use was not a default constructor.

I would expect to get  a message along the lines of C2248: "cannot access
private member declared in class...".

I attached a bit of sample code:
    cl /clr /LD BugDLL.cpp
    cl /clr BugEXE.cpp

-Sean

begin 666 BugEXE.cpp



M#0H)1" J9" ](&YE=R!$*#$I.R O+R!';V]D(&5R<F]R(&UE<W-A9V4-"GT-

`
end

begin 666 BugDLL.cpp


`
end



Sun, 03 Oct 2004 05:12:43 GMT  
 Bad compiler error message.
Sean: this is due to the fact that when the compiler reads meta-data it, in
general, skips any meta-data that is not visible to the client - so in this
case the compiler does not know that there is a private default constructor
so it does not give the more meaningful error message. We are looking into
ways of reading private meta-data in the next release -- the problem is that
some of the other .NET compiler can generate meta-data that the C++ compiler
cannot easily understand.

--
Jonathan Caves
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> If you try to construct an object from an external assembly with only
> internal constructors, you get the error message C2512: "no appropriate
> default constructor available".  I have found this very confusing since
the
> constructor I was trying to use was not a default constructor.

> I would expect to get  a message along the lines of C2248: "cannot access
> private member declared in class...".

> I attached a bit of sample code:
>     cl /clr /LD BugDLL.cpp
>     cl /clr BugEXE.cpp

> -Sean



Sun, 03 Oct 2004 05:32:55 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. worst error message, ever

2. Compiler Error Message: CS0115

3. Mysterious compiler error messages

4. Strange error message of gcc compiler

5. wired compiler error message

6. VC++6.0/SP3 Compiler Error: INTERNAL COMPILER ERROR

7. VC++ 5.0 > Compiler error messages

8. Compiler error messages in .exe file

9. Strange resource compiler error message

10. funny C compiler error messages ...

11. Compiler warnings vs error messages

12. Error-Message by VC++ - Compiler

 

 
Powered by phpBB® Forum Software