Thursday, April 24, 2008

C2860 and C++/CLI

Just for future Googlers, it is possible to get a compile error from the C++/CLI compiler (that is, Visual Studio 2005 compiling C++ code with the /clr switch) which looks like

C2860: 'void' cannot be an argument type, except for '(void)'

This happens at absolutely random places where you reference .NET objects that it should already know about. (The error will further read, if you look at the detailed compiler output, something like " This diagnostic occurred while importing type 'Fred::Ethel ' from assembly 'cppclitestingfs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.")

Muh? It turns out in this case the class I was using used a class in its definition a class which came from another assembly (FSharp.Core, as it turns out, but it could have been anyone.) Instead of saying something useful like 'Fred::Ethel references type Option<A> which is not defined', it said ''void' cannot be an argument type'. Obviously.

My completely un-called for guess? Someone on the C++/CLI compiler team substituted the word 'void', perhaps by accident, when an imported type had an unresolved external reference. Another compiler pass downstream complained quite rightly about this, but lacked context to give a more meaningful message. Is there a place one submits bugs in Microsoft compilers that is not informationally equivalent to a black hole?

2 Comments:

At January 06, 2009 6:20 AM, Blogger Salman said...

Thanks for this post! I was beating my head against the wall trying to figure out why I was getting this error.

 
At December 08, 2009 10:44 AM, Anonymous Anonymous said...

This was a big help to me, too! This is a tricky error, since the type you need to define (in your example, Option<A>) isn't actually mentioned at all. Thus the programmer has to go through the type last mentioned in the diagnostics (here it's Fred::Ethel) and see which types don't have a proper assembly referenced.

 

Post a Comment

Links to this post:

Create a Link

<< Home