Boost logo

Boost :

Subject: Re: [boost] [scope_exit] trunk tests fail on sun compiler
From: lcaminiti (lorcaminiti_at_[hidden])
Date: 2012-04-03 22:05:21


Steven Watanabe-4 wrote
>
> AMDG
>
> On 04/03/2012 06:58 AM, lcaminiti wrote:
>>
>> How would I make Boost.Typeof automatically detect that Sun doesn't
>> support
>> native type-of?
>
> For some reason Boost.Typeof thinks that Sun does
> support native typeof. See boost/typeof/typeof.hpp:158 ff.
>
>> That'd be the best fix for the user. Shall I change
>> Boost.Config, Boost.Typeof, or something else?
>>
>

It looks like there's a problem in Boost.Config that is causing Boost.Typeof
not to work on Sun compilers. Here's what's going on.

1) First of all, I was wrong and Sun supports native type-of using
__typeof__ so Boost.Typeof is right in doing:

#define BOOST_TYPEOF_KEYWORD __typeof__ // boost/typeof/typeof.hpp:158

2) However, the header boost/config/platform/linux.hpp get's included later
by Boost.Typeof and it does:

#ifndef __GNUC__
//
// if the compiler is not gcc we still need to be able to parse
// the GNU system headers, some of which (mainly <stdint.h>)
// use GNU specific extensions:
//
//...
# ifndef __typeof__
# define __typeof__ typeof // boost/config/platform/linux.hpp:103
# endif

This generates and error because Sun has no "typeof" but only "__typeof__"
(note that __typeof__ is not a macro on Sun but still it's what you should
use for type-of).

For example, this code:

#include <boost/confi.hpp>

int main(void) {
    int i = 0;
    __typeof__(i) j = i;
    return 0;
}

Incorrectly replaces __typeof__(i) with typeof(i) and it does not compile
(as I verified on my Linux Sun installation also looking at the preprocessor
output CC -E ...) but it compiles just fine without the #include
<boost/config.hpp> because __typeof__(i) remains unchanged.

I'm not familiar enough with Boost.Config... how can shall
boost/config/platform/linux.hpp:103 be fixed?

Thanks a lot.
--Lorenzo

--
View this message in context: http://boost.2283326.n4.nabble.com/boost-scope-exit-trunk-tests-fail-on-sun-compiler-tp4501546p4530701.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

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