Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2003-06-15 12:15:42


Hmmmm - I never imagined that something like this would be so problematic.

For now with my VC 7.0 compiler I can use the following and it gives
me almost exactly what I need. The warning message points exactly
to the place in my code where I have invoked it - just like BOOST_STATIC_ASSERT.

I would hope something like this could be boostified so that I could use it outside
of a function.

template<bool>
struct warning
{
        typedef int type;
};

template<>
struct warning<true>
{
        typedef char type;
};

#define BOOST_STATIC_WARNING(B) \
{ \
        char x = (warning<B>::type)0xffff; \
}

>I'm not sure that it can be done, or at least done in a way that's
>worth it.

>Warnings are completely non-portable, since:

>1. They have no official standing in the standard, just errors do
>2. They are made up by each compiler vendor
>3. They are 100% legal code, the vendor just doesn't like it

>These combine into something that cannot be generally tested. We would
>have to examine every compiler and make huge conditional test cases.
>And what would happen if someone hates warnings and turns them all off?
> It's not practical.

>Daryle


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk