1

I've been using this code to marshal strings in C++/CLI for a while now. Recently I've updated to VS 2012 RC to try it out. I really liked the simple design, but none of my projects containing clix.h could be compiled. It worked great in 2010... What could be the problem? Thank you for your answers!

Here is compiler output:

  1. Warning C4346: 'clix::detail::IsManagedString::Result'dependent name is not a type.
  2. Error C2988: unrecognizable template declaration/definition
  3. Error C2059: syntax error : '<'
  4. Error C2039: 'Result' : is not a member of '`global namespace''
  5. Error C2143: syntax error : missing ';' before '}'

The code block errors are in:

typename detail::Select<detail::IsManagedString<SourceType>::Result>::Type<
typename detail::StringTypeSelecter<encoding>::Type,
System::String ^>::Result marshalString(SourceType string) {
// Pass on the call to our nifty template routines
return detail::StringMarshaler<
  detail::IsManagedString<SourceType>::Result ? detail::CxxFromNet : detail::NetFromCxx
>::marshal<encoding, SourceType>(string);
}

An example, source file:

#include "clix.h"
int main()
{
}

Clix header file can be found on this link.

4

1 回答 1

2

You could have just posted the issue on my blog, it's not abandoned or anything :)

I happen to have Visual Studio 2012 RC installed and fixed the issue. You can find a new version of the clix header at the location you linked.

Background: it appears Microsofts new compiler is a bit picky regarding typedefs in nested templates whose parent templates are specialized on integer types. In any case, I found a method that works in both Visual C++ 2010 and Visual C++ 2012 RC.

于 2012-07-30T15:37:53.843 回答