I'm trying to convert an old c++ project from VS2003 to VS2019. Part of this, I'm learning, is going from managed C++ to C++ CLI as managed c++ was dropped pretty quickly.
I'm managing for the most part, but I can't seem to figure out what replaces the __typeof keyword. Is there a drop in for this? See below code snippet for context in how it was it's used.
private: System::ComponentModel::IContainer ^ components;
private:
void InitializeComponent(void)
{
this->components = gcnew System::ComponentModel::Container();
System::Resources::ResourceManager ^ resources = gcnew System::Resources::ResourceManager(__typeof(USB::Form1));
.
.
.
}
Additionally, there's another reoccurring identifier, __gc , that I have found some more info on, but am not sure I understand what to replace it with.
Char chars __gc[] = gcnew Char __gc[bytes->Length * 2];
Char hexDigits __gc[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
bool ImageNumberUsed __gc[];
Does anyone have a good grasp on this and know what the proper conversions are given above contexts?
I can't say that I've used much Managed C++, but I can say what the C++/CLI equivalents are.
__typeof(type)
--> type::typeid
typeid
as if it were a static field or property of the given type.System::Type^
.gcnew System::Resources::ResourceManager(USB::Form1::typeid);
__gc[]
--> class cli::array
cli::array
is a full-fledged managed type. You create it with gcnew
, variables are declared with the hat ^
, etc.cli::array
is generic on the type of object stored in the array, and on the number of dimensions in the array (which defaults to 1). The size of the array is specified via a constructor parameter (using parentheses, not square brackets).cli::array
. Square brackets are used for reading & writing values, not for declaring the type, nor for creating the array.^
inside the generic type. Example: cli::array<String^>^ foo = ...
cli::array<System::Char>^ chars = gcnew cli::array<System::Char>(bytes->Length * 2);
cli::array<System::Char>^ hexDigits = { '0', '1', .... };
char
.)cli::array<bool>^ ImageNumberUsed;
(Uninitialized or null until assigned)cli::Array<String^, 2>^ stringGrid = gcnew cli::Array<String^, 2>(10, 10);