
Prompted by http://www.octopull.demon.co.uk/editorial/N8037_Objection.pdf, I have been trying to assess the potential impact of Microsoft C++/CLI on my projects which use many bits of Boost code. How much of Boost, if any, can be compiled and used with the /clr option in force? Perhaps others can give their experience & expertise to help guide me? Some advantages of C++/CLI are pretty obvious, but what are the gotchas? Thanks. Paul -- Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB Phone and SMS text +44 1539 561830, Mobile and SMS text +44 7714 330204 mailto: pbristow@hetp.u-net.com http://www.hetp.u-net.com/index.html http://www.hetp.u-net.com/Paul%20A%20Bristow%20info.html

Paul A Bristow wrote:
Prompted by http://www.octopull.demon.co.uk/editorial/N8037_Objection.pdf,
I have been trying to assess the potential impact of Microsoft C++/CLI on my projects which use many bits of Boost code.
How much of Boost, if any, can be compiled and used with the /clr option in force?
Perhaps others can give their experience & expertise to help guide me?
Some advantages of C++/CLI are pretty obvious, but what are the gotchas?
the advantages of C++/CLI are not obvious to me. Could you enumerate them? Robert Ramey

| -----Original Message----- | From: boost-bounces@lists.boost.org | [mailto:boost-bounces@lists.boost.org] On Behalf Of Robert Ramey | Sent: 01 February 2006 17:05 | To: boost@lists.boost.org | Subject: Re: [boost] Using Boost with C++/CLI? | | Paul A Bristow wrote: | > Prompted by | > http://www.octopull.demon.co.uk/editorial/N8037_Objection.pdf, | > | > I have been trying to assess the potential impact of Microsoft | > C++/CLI on my projects which use many bits of Boost code. | > | > How much of Boost, if any, can be compiled and used with the /clr | > option in force? | > | > Perhaps others can give their experience & expertise to | help guide me? | > | > Some advantages of C++/CLI are pretty obvious, but what are the | > gotchas? | | the advantages of C++/CLI are not obvious to me. Could you | enumerate them? Compatible with Visual Basic ;-) I'm told there are others. Paul

| -----Original Message----- | From: boost-bounces@lists.boost.org | [mailto:boost-bounces@lists.boost.org] On Behalf Of Deane Yang | Sent: 01 February 2006 22:27 | To: boost@lists.boost.org | Subject: Re: [boost] Using Boost with C++/CLI? | | Paul A Bristow wrote: | > Compatible with Visual Basic ;-) | > | | Could you elaborate on this? I use DLL's developed purely in C or C++ | with Visual Basic or at least Excel VBA all the time. No - I'm only asking the questions - raised by Microsoft info & actions. Paul -- Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB Phone and SMS text +44 1539 561830, Mobile and SMS text +44 7714 330204 mailto: pbristow@hetp.u-net.com http://www.hetp.u-net.com/index.html http://www.hetp.u-net.com/Paul%20A%20Bristow%20info.html

Robert Ramey <ramey <at> rrsd.com> writes:
the advantages of C++/CLI are not obvious to me. Could you enumerate them?
Depends on what you compare it to. A few advantages I can see are 1. Compared to some other popular .Net languages - Templates - Stack semantics - Deterministic destruction 2. Compared to C++ - Easy access to a huge "standard" library including GUI, WebServices and databases. I don't know if these things are advantages for your applications or if they outweight the disadvantages but they can for some of mine. I assume a lot of c++ programmers will move in and out of the .Net world and switch between C++ and C++/CLI frequenctly. Boost (and STL) support in both worlds allows both code and knowledge reuse. Not all of boost makes sense to use in C++/CLI but I think some like multi_index, lambda, mpl, tuple and filesystem has a place there.

"Paul A Bristow" <pbristow@hetp.u-net.com> wrote
How much of Boost, if any, can be compiled and used with the /clr option in force?
Almost every valid C++ program is also a valid C++/CLI program. I doubt that you'll see real world code which would cause any problems.There are some valid C++ programs that won't work with /clr or exhibit different behavior. But these are really obscure cases, that you wouldn't write unless you wanted to break /clr compilation ;-) I believe the only one that ever came up in Microsofts own codebase was a #define interface struct which is used by MIDL generated files (interface struct is considered a single identifier here, therefore interface won't be replaced by struct during macro expansion) However, that doesn't mean things would work with managed types. But that really depends on what you're trying to do. For instance, I've used MPL to implement something along the lines of specialization of generics. But since it operates on types it's not too surprising. OTOH, things like boost::unordered_map<String^,String^> won't work for quite obvious reasons (at least with the current language standard)
Some advantages of C++/CLI are pretty obvious, but what are the gotchas?
While Microsoft did an excellent job on source-level compatibility with standard C++, I think they did very poor job on the "C++ culture". When you try to move some code from native to managed (and managed data - raw C++ with /clr yields MSIL code which does not operate on the garbage-collected heap) you'll quickly learn that C++ idioms just don't work very well. Some of the limitations result directly from requirements of the CLR's execution engine while others are just deliberate language design decisions. So the short story: if you only want to integrate some .NET functionality into your existing codebase, just throw /clr at it and you're fine (well, in theory at least ;-) ) Of course, you might want to isolate functionality which relies on the /clr switch. If you want to C++/CLI as a migration path for C++ expertise, then better think twice. It's probably still your best bet, but only because other options are worse :-( Of course, native code continues to work - at least for the forseeable future. Here's the somewhat longer story (which has little relation to Boost), why I feel C++/CLI just doesn't cut it. The are simply so many little and not so little oddities in the language design that developing with C++/CLI is a real pain. To list just some of my pet peeves: (where R,V,N are reference, value and native - standard C++ class - types). These only apply to the extensions. So long as you use standard C++ code, the standard C++ semantics are preserved. - overloaded operators apply to both pointer types (R^,V^) and class types (R,V). - constructor & destructor model tied to incompatible IDisposable model, so your code should expect that your destructor may be called on partially constructed objects and the destructor be called more than once - Support for types with reference semantics is fairly limited (no R% can have static or dynamic storage duration) - no support for const member functions, which makes working with const managed objects/references a pain. - Value types can't have special member functions - Type symmetry is broken for reference and value types. R^,R% act much like N* and N&. V^,V% have entirely different semantics. Which also causes taking the address of a V% or dereferencing a V^ to return a temporary. - Objects of managed class types can't have static storage duration. And these are only the things of the language design. Then there's also the .NET base class library. Designing a class library, especially of the size of the .NET BCL, is quite difficult. Apparently, Microsoft thought they could do better than others. Well, judge for yourself (one of my favorites is http://msdn2.microsoft.com/library/d312z50h(en-US,VS.80).aspx) I think it's one step forward and two steps back. I spent quite a bit of time on sorting out all kinds of ABI issues on Intel's XScale compiler. The ARM EABI is the most ambitious one I know of in terms of object-level compatibility, but still it doesn't even try to standardize things in presence of Standard C++ library functionality. That's were the CLR type system really shines. However, it also imposes serious restrictions on your code. Single-inheritance only, only weak construction & destruction guarantees, can't have leightweight managed pointer members. And if you care about compatibility with other managed languages you also can't use objects of class type or references to class types in your public interface or even free (namespace-scope non-member) functions. Just my two cents. -hg

Holger Grund wrote:
Almost every valid C++ program is also a valid C++/CLI program. I doubt that you'll see real world code which would cause any problems.
I'm told that boost.threads don't like .NET. -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/

boost shared_ptr cannot be used as member variables in a manage class (not any other unmanged class that has a copy constructor). Another thin to note, when you do compile code using boost, the boost classes appear in the .NET assembly as value types (but totally unusable from other .NET languages except C++). "Maciej Sobczak" <prog@msobczak.com> wrote in message news:43E131F1.8080908@msobczak.com...
Holger Grund wrote:
Almost every valid C++ program is also a valid C++/CLI program. I doubt that you'll see real world code which would cause any problems.
I'm told that boost.threads don't like .NET.
-- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/ _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (7)
-
Blaine Brysh
-
Deane Yang
-
Holger Grund
-
Maciej Sobczak
-
Martin Adrian
-
Paul A Bristow
-
Robert Ramey