Boost logo

Boost Users :

From: Edward Diener (eldiener_at_[hidden])
Date: 2006-12-14 17:42:20


Séverin Lemaignan wrote:
> Hello,
>
> I'm Severin Lemaignan, software engineer at the INRIA french public
> research center. We are working on automation in public transportation.
> All our project is currently a pretty big C++/CLI-based piece of software,
> and we are relying more and more on Boost for low-level operations like
> threading.
>
> We ran very recently into a problem with Boost mutexes:
>
> We compile the project with Visual Studio 2005 (with the /clr flag), and
> everything was fine until we (re-)enabled precompiled headers.
>
> After that, the program still compiled and linked but it crashed as soon
> as started with a 0xc000007b error (namely "The application failed to
> initialize properly").
>
> After futher investigation, we discovered it's due to the way we use
> "#pragma unmanaged" and "#pragma managed". The Boost headers were simply
> included in a "managed" part of the code while Boost methods (especially
> mutexes) were called in a "unmanaged" part. Hence causing the crash.

I have not used the Boost threading library but I have done much C++/CLI
programming.

>
> The Boost library never complained at compile time. Maybe it should
> detect inconsistent use of managed/unmanaged pragma and warn the user ?

How would it do this ? It can know whether the _MANAGED preprocessor
define is defined or not in a particular usage, but it can not know
between one use of it or another whether _MANAGED is being defined or
not, and somehow report an error if it s not.

I think it is up to the user to make sure that code using a library is
defined as managed or unmanaged consistently in a C++/CLI module.

Generally in a C++/CLI module, the code is always being compiled as
managed code, even when it is a C++ class as opposed to a ref class. if
you are manually controlling this by using the "#pragma unmanaged" and
"#pragma managed" directives, then it would seem to me that it is up to
you to determine this being used consistently.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net