Boost logo

Boost Users :

From: Edward Diener (eddielee_at_[hidden])
Date: 2006-03-29 10:50:14


When compiling managed code in VC++ .NET, which is any of the /clr
compiler options, the programmer can mix both CLR classes and regular
C++ classes. In the regular C++ classes, Boost should work fine. The
VC++ macro which tells one that managed code of any kind is being
compiled is _MANAGED, which is defined if managed code is being compiled
else it is not defined. So when any of the /clr compiler options are
being used _MANAGED is defined, else it is not defined.

The VC++ compiler issues compiler warning C4561 whenever managed code is
being compiled and __fastcall shows up as a calling convention in any
way. Obviously the programmer can turn off this warning via a VC++
#pragma, but I am wondering if Boost could not change some of its
headers to avoid this warning. In Boost bind and mem_fn, the programmer
has to specifically ask for __fastcall support via special Boost macros
to have any functions declared with the __fastcall calling convention,
so nothing should be done there since it is clearly a programming error
if he does so while compiling managed code.

However there are two other places in Boost which I have discovered
where functions with the __fastcall calling convention are declared
without the programmer doing anything.

The first, and most cumbersome reagrding warning messages, is in
type_traits in the helper header files
type_traits\detail\is_mem_fun_pointer_tester.hpp and
type_traits\detail\is_function_pointer_tester.hpp. Since many other
libraries, lambda in my case recently, uses type_traits, might not these
headers be changed so that when VC++ is the compiler and _MANAGED is
defined, the __fastcall versions of these helper functions are not
declared ?

The second, which I have not encountered but which I saw while searching
through Boost header code, is in regex\config.h and I do not know, given
some other macros there, whether BOOST_REGEX_CALL can ever be __fastcall
when compiling with /clr, but if it can perhaps a change can be made
there also.

I know that it is not the purpose of Boost to try to accomodate C++ .NET
programmers creating /clr compilations using Boost, especially when just
warnings and not errors are issued. But in this case, using the
predefined macro _MANAGED in VC++ and BOOST_MSVC, it would seem this
acoomodation could be made. So I would like the Boost developers of
type_traits, especially since it is used by so many other Boost
libraries, and regex to consider it.


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