Boost logo

Boost-Build :

Subject: Re: [Boost-build] Python port development
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-07-09 15:56:32


Artyom wrote:
> That is exactly the way it should not be done, and that is exactly the reason
> you
> should give it to build system:
> Why it can't be done using printing the sizeof: It does not work when you cross
> compile,

Oh. Right.

> How can we check for example if sizeof(wchar_t) >= 4?

There are many ways to trigger a compiler error in C++.
In C, yeah, a negative array size is probably the easiest.

> char test[sizeof(wchar_t)*2 - 7]
> If sizeof(wchar_t) == 4 then 4*2-7 == 1 and the code is legal and compilation
> succeeds,
> If sizeof(wchar_t) == 2 then 2*2 - 7 == -3 and this code is not legal and
> compilation fails.
> It is very tricky to implement this correctly.

How is this particularly tricky? I can see that it would get tedious
is the size is not known to be one of a few possibility (thus requiring
a binary search), but it seems like this is rather the obvious solution
when running a compiled program isn't possible.

> This is why it shouldn't be done
> by users
> as most of them would use the solution you had suggested, and it is wrong.
> Just to make it clear, even CMake had done this right only recently, before this
> it was implemented
> incorrectly. This solution was discovered very long time ago by autotools.

In Christ,
Steven Watanabe

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at