c++-cli

Implementing IEnumerable<T> in C++/CLI

a 夏天 提交于 2020-01-01 08:03:12
问题 I'm having problems implementing IEnumerable<T> in my custom collection class in C++/CLI. Here is the relevant part of the code: using namespace System::Collections::Generic; ref class MyCollection : IEnumerable<MyClass^> { public: MyCollection() { } virtual IEnumerator<MyClass^>^ GetEnumerator() { return nullptr; } }; When compiled, this results in the following errors: error C2392: 'System::Collections::Generic::IEnumerator ^MyCollection::GetEnumerator(void)': covariant returns types are

C++/CLI equivalent of C#'s 'readonly' keyword

﹥>﹥吖頭↗ 提交于 2020-01-01 07:33:16
问题 What's the C++/CLI equivalent of C#'s readonly keyword? Specifically, how do you write a public or protected member of a C++/CLI class such that it is readonly when referenced from C#? 回答1: I just found out (thanks to Literal field versus constant variable in C++/CLI) that C# const is literal in C++/CLI, and C# readonly is initonly in C++/CLI 来源: https://stackoverflow.com/questions/7469224/c-cli-equivalent-of-cs-readonly-keyword

unsigned char* buffer to System::Drawing::Bitmap

左心房为你撑大大i 提交于 2020-01-01 06:27:07
问题 I'm trying to create a tool/asset converter that rasterises a font to a texture page for an XNA game using the FreeType2 engine. Below, the first image is the direct output from the FreeType2]1 engine. The second image is the result after attempting to convert it to a System::Drawing::Bitmap . target http://www.freeimagehosting.net/uploads/fb102ee6da.jpg currentresult http://www.freeimagehosting.net/uploads/9ea77fa307.jpg Any hints/tips/ideas on what is going on here would be greatly

Error -1073741819 (0xC0000005) when executing AL.EXE from Post-Build event in Visual Studio 2015 Update 1

我只是一个虾纸丫 提交于 2020-01-01 05:18:26
问题 Using Visual Studio 2015 Update 1, I'm experimenting a problem (that didn't happened with Visual Studio 2015) in a Visual C++ CLR class library project (C++/CLI) when running the command AL.EXE in Post-Build Event: The AL.EXE application crashed and the system returns the error code -1073741819 (0xC0000005). Here the contents of the post-build event: sn -Rca "$(SolutionDir)bin\$(Configuration)\$(Platform)\$(TargetName)$(TargetExt)" dwo Resgen "$(ProjectDir)Recursos.es-ES.resx" "$(IntDir)$

How expensive is it to convert between int and double?

女生的网名这么多〃 提交于 2019-12-31 18:58:56
问题 I often see code that converts ints to doubles to ints to doubles and back once again (sometimes for good reasons, sometimes not), and it just occurred to me that this seems like a "hidden" cost in my program. Let's assume the conversion method is truncation. So, just how expensive is it? I'm sure it varies depending on hardware, so let's assume a newish Intel processor (Haswell, if you like, though I'll take anything). Some metrics I'd be interested in (though a good answer needn't have all

How expensive is it to convert between int and double?

微笑、不失礼 提交于 2019-12-31 18:57:45
问题 I often see code that converts ints to doubles to ints to doubles and back once again (sometimes for good reasons, sometimes not), and it just occurred to me that this seems like a "hidden" cost in my program. Let's assume the conversion method is truncation. So, just how expensive is it? I'm sure it varies depending on hardware, so let's assume a newish Intel processor (Haswell, if you like, though I'll take anything). Some metrics I'd be interested in (though a good answer needn't have all

How expensive is it to convert between int and double?

天涯浪子 提交于 2019-12-31 18:57:32
问题 I often see code that converts ints to doubles to ints to doubles and back once again (sometimes for good reasons, sometimes not), and it just occurred to me that this seems like a "hidden" cost in my program. Let's assume the conversion method is truncation. So, just how expensive is it? I'm sure it varies depending on hardware, so let's assume a newish Intel processor (Haswell, if you like, though I'll take anything). Some metrics I'd be interested in (though a good answer needn't have all

Linking error while in C++/CLI project while wrapping C++ shared library

本小妞迷上赌 提交于 2019-12-31 05:37:24
问题 I am trying to wrap C++ library to that managed projects can use it. The third party library I am using is a shared library. It's meant to link on load time. I have header files, .lib file which is DLL import library and .DLL file. This is what I did so far:- 1. Created CLR project. 2. Added path for header file in C/C++->General->Additional Include Directories 3. Set 'Additional Library Directories' in Linker->General. 4. Added lib name in Linker->Input->Additional Dependencies After I do

Link error linking from managed to unmanaged C++ despite linking to .lib file with exported symbols

╄→尐↘猪︶ㄣ 提交于 2019-12-31 04:05:45
问题 Despite following various posts on using and linking to unmanaged C++ code from a C++/CLI wrapper dll, I cannot resolve these link issues. 1>MyClassAdapter.obj : error LNK2028: unresolved token (0A00000A) "public: __thiscall MyClass::~MyClass(void)" (??1MyClass@@$$FQAE@XZ) referenced in function "public: void * __thiscall MyClass::`scalar deleting destructor'(unsigned int)" (??_GMyClass@@$$FQAEPAXI@Z) 1>MyClassAdapter.obj : error LNK2028: unresolved token (0A00000B) "public: __thiscall

Converting textbox string to float?

可紊 提交于 2019-12-31 03:35:07
问题 I'm basically trying to write a basic converter in visual studio 2008, and I have 2 text boxes, one which gets input from the user, and one which gives output with the result. When I press the button I want the input from the first textbox to multiply by 4.35 then display in the 2nd textbox. This is my code in the button code so far: String^ i1 = textBox1->Text; float rez = (i1*4.35)ToString; textBox2->Text = rez; However I'm getting these errors: f:\microsoft visual studio 9.0\projects