|
Boost : |
From: Brian McNamara (lorgon_at_[hidden])
Date: 2004-04-15 02:20:22
On Thu, Apr 15, 2004 at 10:46:23AM +0400, Vladimir Prus wrote:
> Hello,
> I've just found out that the following program:
>
> #include <boost/static_assert.hpp>
>
> int main()
> {
> BOOST_STATIC_ASSERT(false);
> return 0;
> }
>
> compiled with gcc 3.3 produces:
>
> sa.cpp:6: error: invalid application of `sizeof' to an incomplete type
I'm kinda hijacking your message topic (apologies) but...
More generally, I would really like a Boost library which lets me
generate custom error messages portably. For example, with FC++, I
spent a bit of time getting g++ to give "nice" diagnostics for certain
kinds of errors -- for instance, compiling
// uh oh...
cout << lambda(X,X)[ X ](1,2) << endl; // lam2.cpp line 94
with g++-3.1.1 yields
lambda.hpp: In function
`boost::fcpp::lambda_impl::LambdaThingy<
boost::fcpp::lambda_impl::exp::CONS<
boost::fcpp::lambda_impl::exp::lambda_var<i>,
boost::fcpp::lambda_impl::exp::CONS<
boost::fcpp::lambda_impl::exp::lambda_var<i>,
boost::fcpp::lambda_impl::exp::NIL> > >
boost::fcpp::lambda_impl::lambda(const
boost::fcpp::lambda_impl::exp::lambda_var<i>&, const
boost::fcpp::lambda_impl::exp::lambda_var<i>&) [with int i = 4, int
j = 4]':
lam2.cpp:94: instantiated from here
lambda.hpp:1137: no method `boost::fcpp::lambda_impl::
YouCannotPassTheSameLambdaVarTo_lambda_MoreThanOnce<true>::go'
I am happy with the last two lines of the error message, which indicate
both the source of the problem (lam2.cpp, line 94) and the issue
(YouCannotPassTheSameLambdaVarTo_lambda_MoreThanOnce). However I got
this working using completely ad-hoc techniques which maybe only work
well for g++-3.1.1.
What I would really love is if there were a boost library which enabled
me to dispatch messages along the lines of
BOOST_CUSTOM_ERROR( b, msg )
BOOST_CUSTOM_WARNING( b, msg )
where in both cases "b" is a compile-time boolean, "msg" is the name of
a type, and the behavior is
if the boolean is true
force this compiler to generate a short diagnostic with typename
"msg" featured prominently
In the long run, there really needs to be language support for
meta-programs to generate legible diagnostics, but in the meantime, I
would love a stopgap solution along the lines above. I think it would
"only" involve the work of finding the best "trick" for each compiler
brand/version. Perhaps a little concerted effort would discover one
trick which worked well across many compilers.
Is there interest in this?
-- -Brian McNamara (lorgon_at_[hidden])
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk