Click here to Skip to main content
15,909,039 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: Use native C++-DLLs with managed C++ or C#? Pin
Luc Pattyn23-May-09 6:17
sitebuilderLuc Pattyn23-May-09 6:17 
GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
Unbe Kant23-May-09 8:24
Unbe Kant23-May-09 8:24 
GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
Luc Pattyn23-May-09 8:57
sitebuilderLuc Pattyn23-May-09 8:57 
GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
Unbe Kant23-May-09 12:07
Unbe Kant23-May-09 12:07 
GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
Luc Pattyn23-May-09 12:35
sitebuilderLuc Pattyn23-May-09 12:35 
GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
Unbe Kant23-May-09 13:22
Unbe Kant23-May-09 13:22 
GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
led mike27-May-09 5:01
led mike27-May-09 5:01 
GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
Luc Pattyn27-May-09 5:50
sitebuilderLuc Pattyn27-May-09 5:50 
Hi Mike,

there is a lot you wrote/copied/linked to that I agree with. Even when some of it may sound a little biased (MS has to promote .NET, has to make clear what the position is with repect to C++, it is only normal compilers and code generators get improved, etc).

However it is besides the point I was making or trying to make: once it has been decided a mixture of managed code and native code is needed (maybe because of existing native code), making the two worlds cooperate often can be achieved with C# and P/Invoke as efficiently and with the same performance as can be done with C++/CLI. I am not saying C# is better or worse than C++/CLI, I am only referring to its ability to interface well with the native world.

I have been doing a lot of interop over the years, dealing with huge amounts of numeric data going back and forth, and the one thing that really matters performance-wise is the data does not get copied. Well, that can be organized by allocating managed buffers (e.g. int arrays), then passing pointers (I tend to use GCHandle for that, even when sometimes a simple fixed would suffice).

Example: I created an image processing library using run-time generated assembly code (including MMX/SSE for Intel x86 and Altivec for PowerPC) and called from both .NET (C#, using P/Invoke) and Java (using some kind of JNI); the code was not PC specific, it had to run on non-Windows embedded systems too. In the end the SIMD code was almost as fast as a copy operation, so adding one or two copy operations to it would be unacceptable.

Some people claim the best way to call native code from C# is by providing a C++/CLI wrapper, and maybe this is correct for complex data structure situations (not sure), but I object to those anyway. KISS is one of my motto's, and with a KISS interface, C# + P/Invoke works great.

Hence my statement: "IMO the rumors of C++/CLI being much better at interop than C# are highly overrated."

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
N a v a n e e t h27-May-09 17:22
N a v a n e e t h27-May-09 17:22 
QuestionResizing of Labels in Controls Pin
cherrymotion21-May-09 21:23
cherrymotion21-May-09 21:23 
AnswerRe: Resizing of Labels in Controls Pin
N a v a n e e t h21-May-09 21:54
N a v a n e e t h21-May-09 21:54 
GeneralRe: Resizing of Labels in Controls Pin
cherrymotion21-May-09 22:16
cherrymotion21-May-09 22:16 
QuestionRe: Resizing of Labels in Controls Pin
led mike22-May-09 4:26
led mike22-May-09 4:26 
AnswerRe: Resizing of Labels in Controls Pin
cherrymotion22-May-09 8:25
cherrymotion22-May-09 8:25 
GeneralRe: Resizing of Labels in Controls [modified] Pin
Luc Pattyn22-May-09 9:40
sitebuilderLuc Pattyn22-May-09 9:40 
QuestionSending events to main window of another process Pin
parth_patel21-May-09 5:34
parth_patel21-May-09 5:34 
QuestionRe: Sending events to main window of another process Pin
led mike21-May-09 5:48
led mike21-May-09 5:48 
AnswerRe: Sending events to main window of another process Pin
parth_patel21-May-09 6:05
parth_patel21-May-09 6:05 
GeneralRe: Sending events to main window of another process Pin
led mike21-May-09 7:50
led mike21-May-09 7:50 
GeneralRe: Sending events to main window of another process Pin
parth_patel21-May-09 10:58
parth_patel21-May-09 10:58 
GeneralRe: Sending events to main window of another process Pin
parth_patel27-May-09 9:23
parth_patel27-May-09 9:23 
AnswerRe: Sending events to main window of another process Pin
Mark Salsbery21-May-09 7:23
Mark Salsbery21-May-09 7:23 
GeneralRe: Sending events to main window of another process Pin
led mike21-May-09 7:50
led mike21-May-09 7:50 
QuestionProblem getting exact response through webrequest Pin
naveen_bij18-May-09 21:54
naveen_bij18-May-09 21:54 
QuestionDelegates and Event in VC.Net Pin
savitri18-May-09 19:40
savitri18-May-09 19:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.