Why using boost::function with lambda requires RTTI?
I am using CodeWarrior 9.3 for Palm OS development and I was looking at the possibility of using boost::function class in my code. Because my application is big and the data segment is already almost full (even if I uses extended mode), I do not want to uses RTTI (at all, if possible). When I compile the code I get the following warning "RTTI option is disabled" at the line with the following macro call BOOST_FUNCTION_COMPARE_TYPE_ID in function boost::detail::function::functor_manager::manage(). Also, a lambda function like (((1.0 * _1 + 2.0) * _1 + 3.0) * _1 + 4.0) * _1 + 5.0 cause my data segment to increase of 6K which is huge when the limit is 64K... Using a static function (and not using boost::lambda) instead does not cause such increase of the use of the data segment. Another thing that I have noticed is that the compiler get very slow as I am starting to uses some boost libraries like that (a few more seconds per file). Philippe
On Jan 6, 2005, at 5:25 PM, Philippe Mori wrote:
When I compile the code I get the following warning "RTTI option is disabled" at the line with the following macro call BOOST_FUNCTION_COMPARE_TYPE_ID in function boost::detail::function::functor_manager::manage().
Function allows you to ask about the return type (via boost::function<...>::type()) and to extract the type, for which it needs RTTI. However, this feature could be #ifdef'd out. We had (briefly) discussed adding a BOOST_NO_RTTI macro for this purpose back in September. Perhaps it's time to reopen that discussion.
Also, a lambda function like (((1.0 * _1 + 2.0) * _1 + 3.0) * _1 + 4.0) * _1 + 5.0 cause my data segment to increase of 6K which is huge when the limit is 64K...
Using a static function (and not using boost::lambda) instead does not cause such increase of the use of the data segment.
I'm surprised that the increase is so large, but not that it exists. _1, _2, etc. are namespace-level variables (by necessity) and will be replicated in each translation unit where they are used.
Another thing that I have noticed is that the compiler get very slow as I am starting to uses some boost libraries like that (a few more seconds per file).
The curse of template-heavy code :( There isn't much we can do about this, unfortunately. Doug
Douglas Gregor wrote:
On Jan 6, 2005, at 5:25 PM, Philippe Mori wrote:
When I compile the code I get the following warning "RTTI option is disabled" at the line with the following macro call BOOST_FUNCTION_COMPARE_TYPE_ID in function boost::detail::function::functor_manager::manage().
Function allows you to ask about the return type (via boost::function<...>::type()) and to extract the type, for which it needs RTTI. However, this feature could be #ifdef'd out. We had (briefly) discussed adding a BOOST_NO_RTTI macro for this purpose back in September. Perhaps it's time to reopen that discussion.
Also, a lambda function like (((1.0 * _1 + 2.0) * _1 + 3.0) * _1 + 4.0) * _1 + 5.0 cause my data segment to increase of 6K which is huge when the limit is 64K...
Using a static function (and not using boost::lambda) instead does not cause such increase of the use of the data segment.
I'm surprised that the increase is so large, but not that it exists. _1, _2, etc. are namespace-level variables (by necessity) and will be replicated in each translation unit where they are used.
But they shouldn't be. We have to get them out of the unnamed namespace anyway for ODR reasons. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
participants (3)
-
David Abrahams
-
Douglas Gregor
-
Philippe Mori