Open JSandusky opened 8 years ago
I also encountered a loosely similar issue with functions returning std::string being expanded into std::basic_string() (without type args) for return as a System::String^, only mentioning because from a superficial look it might be related.
I resolved that just by post-processing the code because all cases were completely identical in output.
Most functions wanted to print as (good):
System::String^ SprueBind::SpruePiece::GetName()
{
auto __ret = ((::SprueEngine::SpruePiece*)NativePtr)->GetName();
return clix::marshalString<clix::E_UTF8>(__ret);
}
But a few printed as (bad):
System::String^ SprueBind::Deserializer::GetName()
{
auto &__ret = ((::SprueEngine::Deserializer*)NativePtr)->GetName();
return (System::String^)((&__ret == nullptr) ? nullptr : gcnew std::basic_string((::std::basic_string*)&__ret));
}
Header for the example good case:
std::string GetName() const { return name_; }
Header for the example bad case:
std::string ReadString();
The cleanup code used (to make things dandy):
if (lines[i].Contains("gcnew std::basic_string((::std::basic_string*)&__ret))"))
lines[i] = lines[i].Replace("gcnew std::basic_string((::std::basic_string*)&__ret))", "gcnew System::String(__ret.c_str()))");
Again, having not investigated, unsure of any interrelation.
Brief Description
Given this code containing a static const for "zero" (last real line of code):
I apologize, post height is a bit large, but still fell small enough that I felt inline was okay.
Input C++ Header
The output source to CLI is (note, the CPP file is the meaningful one here):
CLI Output Header file
Output CLI CPP file (only problem section)
That source output in the CPP isn't sane (nor compilable). The variable name is invalid and the ternary really doesn't make any sense.
Easy to work around though using a special #ifndef and adding that to the driver options as a define.
OS: Windows Target: MSVC 2013, C++11, CLI output