Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Managed C++ for .NET CF?

3 views
Skip to first unread message

Eugene Mayevski

unread,
Dec 31, 2004, 2:01:58 PM12/31/04
to
Hello!

We have an assembly written in managed C++ (this is needed cause it
incapsulates large amount of platform-independent C code). The same code is
compiled ok with eVC 4. Is there a chance to compile Managed C++ assembly
which can be used in .NET CF? I understand that we can create a DLL with eVC
and use P/Invoke to call the DLL from .NET CF, but we'd prefer an assembly
if possible. Thanks in advance.

With best regards,
Eugene Mayevski.

Daniel Moth

unread,
Dec 31, 2004, 2:43:28 PM12/31/04
to
Only VB.NET & C# are supported on the CF.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


"Eugene Mayevski" <maye...@eldos.org> wrote in message
news:eVmqRt27...@TK2MSFTNGP15.phx.gbl...

Ilya Tumanov [MS]

unread,
Dec 31, 2004, 2:42:34 PM12/31/04
to
No, you can not, sorry. Managed C++ is not supported by CF runtime.

You can try it on your own risk, but it probably won't even compile not to
mention running.
That's because managed C++ compiler can use some worker routines missing or
working differently on CF.

I suppose you can decompile managed DLL into IL, remove/replace all
unsupported calls and compile it back, but it's probably not worth it.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
> From: "Eugene Mayevski" <maye...@eldos.org>
> Subject: Managed C++ for .NET CF?
> Date: Fri, 31 Dec 2004 21:01:58 +0200
> Lines: 12
> MIME-Version: 1.0
> Content-Type: text/plain;
> charset="koi8-r"
> Content-Transfer-Encoding: 7bit
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
> X-Comment-To: All
> Message-ID: <eVmqRt27...@TK2MSFTNGP15.phx.gbl>
> Newsgroups: microsoft.public.dotnet.framework.compactframework
> NNTP-Posting-Host: ip.82.144.219.9.dyn.pool-1.broadband.voliacable.com
82.144.219.9
> Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15
.phx.gbl
> Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:67789
> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Eugene Mayevski

unread,
Dec 31, 2004, 3:13:12 PM12/31/04
to
Hello!
You wrote on Fri, 31 Dec 2004 19:42:34 GMT:

ITM> No, you can not, sorry. Managed C++ is not supported by CF runtime.

Hmm. An interesting statement ("supported by CF runtime"). As I understand,
the language compiler accomodates the generated code to target platform. Or
this is not the case for .NET CF and the runtime has explicit support for
certain VB- and C#-specific code?

Also, with upcoming VS.NET 2005 (which includes native code generation for
WinCE), will the situation become different, i.e. will Managed C++ support
be added?

With best regards,
Eugene Mayevski

Ilya Tumanov [MS]

unread,
Dec 31, 2004, 4:26:01 PM12/31/04
to
C# and C++ .NET compilers are using some special functions at runtime (say,
in System.Runtime.CompilerServices) for same statements.
VB needs even more support from runtime to implement VB6 compatible
functionality.
This is not that unusual if you consider some C# statements (e.g. 'foreach'
and 'using') can actually use your custom code to operate.

CF only implements a subset of these workers. Some functions used by
Managed C++ are not implemented.
In fact, even some functions used by C# are not implemented.

For example, try compiling this C# code for CF: volatile int a;
Or, try getting unsafe pointer to a string (both fixed in V2).

Upcoming CF V2 won't support Managed C++, sorry. The demand for it was
very low compared to other features.
I would guess there's no good reason to use Managed C++ for new projects
and there's not that much legacy C++ code for PPC.
Also, there are workarounds like using native C++ (with significant
performance benefits) or even porting C/C++ to C#.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
> From: "Eugene Mayevski" <maye...@eldos.org>

> References: <eVmqRt27...@TK2MSFTNGP15.phx.gbl>
<VSMZhD3...@cpmsftngxa10.phx.gbl>
> Subject: Re: Managed C++ for .NET CF?
> Date: Fri, 31 Dec 2004 22:13:12 +0200
> Lines: 17


> MIME-Version: 1.0
> Content-Type: text/plain;
> charset="koi8-r"
> Content-Transfer-Encoding: 7bit
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441

> X-Comment-To: "Ilya Tumanov [MS]"
> Message-ID: <OtF0vc37...@tk2msftngp13.phx.gbl>


> Newsgroups: microsoft.public.dotnet.framework.compactframework
> NNTP-Posting-Host: ip.82.144.219.9.dyn.pool-1.broadband.voliacable.com
82.144.219.9
> Path:

cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
.phx.gbl
> Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:67793
> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Eugene Mayevski

unread,
Dec 31, 2004, 4:32:32 PM12/31/04
to
Hello!
You wrote on Fri, 31 Dec 2004 21:26:01 GMT:

ITM> Upcoming CF V2 won't support Managed C++, sorry. The demand for it
ITM> was very low compared to other features.
ITM> I would guess there's no good reason to use Managed C++ for new
ITM> projects and there's not that much legacy C++ code for PPC.
ITM> Also, there are workarounds like using native C++ (with significant
ITM> performance benefits) or even porting C/C++ to C#.

Thank you for the detailed answer. Porting doesn't have much sense (the code
is maintained and developed further) so using P/Invoke seems to be the best
way ...

Ginny Caughey [MVP]

unread,
Jan 3, 2005, 9:26:12 AM1/3/05
to
Ilya,

One thing that may change the landscape for Managed C++ on devices is that
the devices are becoming increasingly powerful as well as widespread in the
marketplace. I am aware of a commercial project that involves porting
existing managed C++ code to devices now, and a few years ago I doubt that
would have happened. They have it working, but as you pointed out it wasn't
an easy thing to do. They did tell me that if the Managed C++ compiler just
had a switch that would warn them what code wasn't supported on .NetCF, that
would have helped a lot - so maybe in a future version this could be
considered.

Ginny Caughey
.Net Compact Framework MVP

""Ilya Tumanov [MS]"" <ily...@online.microsoft.com> wrote in message
news:o05bV937...@cpmsftngxa10.phx.gbl...

Ilya Tumanov [MS]

unread,
Jan 3, 2005, 6:29:41 PM1/3/05
to
I'm sorry, I'm confused. Do you mean this project was done using managed C++
on CF?

Or was it ported to native C++?

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.


" Ginny Caughey [MVP]" <ginny.caug...@wasteworks.com> wrote in
message news:ONaquAa8...@TK2MSFTNGP09.phx.gbl...

Ginny Caughey [MVP]

unread,
Jan 3, 2005, 9:01:46 PM1/3/05
to
Hi Ilya,

It's managed C++.

Ginny

"Ilya Tumanov [MS]" <ily...@online.microsoft.com> wrote in message

news:41d9d568$1...@news.microsoft.com...

Ilya Tumanov [MS]

unread,
Jan 4, 2005, 4:59:57 PM1/4/05
to
That's quite interesting (though I sure have to condemn using not supported
solution even though it is successful :).

So, how exactly this is done? Was source code adjusted so compiler won't
produce unsupported IL instructions and runtime calls?
Or was it some sort of IL filter?

I would also suggest filing a feature request for Managed C++ on CF here:
http://lab.msdn.microsoft.com/productfeedback/default.aspx

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

> From: " Ginny Caughey [MVP]" <ginny.caug...@wasteworks.com>
> References: <eVmqRt27...@TK2MSFTNGP15.phx.gbl>
<VSMZhD3...@cpmsftngxa10.phx.gbl>
<OtF0vc37...@tk2msftngp13.phx.gbl>
<o05bV937...@cpmsftngxa10.phx.gbl>
<ONaquAa8...@TK2MSFTNGP09.phx.gbl> <41d9d568$1...@news.microsoft.com>


> Subject: Re: Managed C++ for .NET CF?

> Date: Mon, 3 Jan 2005 21:01:46 -0500
> Lines: 134
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
> X-RFC2646: Format=Flowed; Response
> Message-ID: <e56KTFg8...@TK2MSFTNGP15.phx.gbl>
> Newsgroups: microsoft.public.dotnet.framework.compactframework
> NNTP-Posting-Host: ilm74-238-211.ec.rr.com 24.74.238.211
> Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15
.phx.gbl
> Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:67871
> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Ginny Caughey [MVP]

unread,
Jan 4, 2005, 9:07:02 PM1/4/05
to
Hi Ilya,

The source was adjusted to only produce suppored IL and runtime. The guy who
did most of the work told me it was partly trial and error because he didn't
always know until runtime that he'd used something not supported, and even
then the error (or more likely just wrong behavior) he got at runtime didn't
necessarily indicate what he'd done wrong - hence the request for a compiler
switch that would throw a warning for something not supported on CF.

I wouldn't recommend using an unsupported solution either, but the guys are
happy with the result, which they say performs significantly faster than
they expected it would - even on the desktop. And now they know what not to
do. ;-)

I'll fill out the feature request - good idea.

Ginny


""Ilya Tumanov [MS]"" <ily...@online.microsoft.com> wrote in message

news:qNVj9iq8...@cpmsftngxa10.phx.gbl...

Bela Istok

unread,
Mar 26, 2005, 10:48:13 PM3/26/05
to
I have some code In Managed C++ runing in the Compact Framework.

I have done a implementation in C# and in Managed C++ (almost the same
code), in C# using the unsafe (to use the pointers like in C++), and
get that the C++ code is almost 1/3 faster that the code produced in
the C# compiler.

0 new messages