When I started my latest project where I needed some basic C libraries to access the Hardware. I thought I will use a Windows Forms Application with C++. I hoped this offers me writing normal C++ code and still use the new UI code from MS. In addition it would possible to port the application since the underlying C library is platform independent and C++ if correctly separated from the UI code should compile as well.
To bad it was not as easy as I hoped it will. The next time I might just chose an MFC Application where I can write native C++ code and I don’t have to bother with some magic C++ addition.
I had quite a hard time to figure out how I need to structure my application that it will work in managed mode. After some googeling I figured out that there are two different things: Managed C++ and C++/CLI. Managed C++ was the old addition from MS. With Visual Studio 2005 they added C++/CLI which is an ECMA standard and has a similar scope as Managed C++. The keywords of C++/CLI are no more marked with two underlines in front as it was with Managed C++. At the end I found an overview that explained me the strange keywords that I found in the new generated code.
The following links give a good overview about the differences between the C++ and C++/CLI:
The result of all this is that my application will not be portable at all since all the code is infected with CLI code. It would have been possible to separate the C++ code from the CLI code in such a way that it could be reused on an other platform but since it is only a prototype and it just has to work on windows. I will leave that for an other time. To separate C++ code from C++/CLI code it is necessary to write some glue code since CLI does not support all features from C++.