On 29 Jun 2017, at 19:16, Mark Millard <markmi_at_dsl-only.net> wrote: > > On 2017-Jun-29, at 5:54 AM, Konstantin Belousov <kostikbel at gmail.com> wrote: >> >> On Thu, Jun 29, 2017 at 12:47:10PM +0200, Dimitry Andric wrote: >>> One nasty problem with this is that it is not possible to figure out at >>> compile time what the size of time_t is. You always need some sort of >>> configure-time test, and an external define. >> >> It is arguably possible, with constexpr. > > I took Dimitry's wording as probably referring to > testing the size in the C/C++ preprocessor like > the original code tests for __LP64__ being defined > vs. not to control what it does: extending that to > involve more preprocessor tests to pick from more > code blocks. (But it is a guess given his wording.) Yeah, what I meant is that the code does something like: #if __LP64__ static_assert(whatever, "foo"); #else static_assert(otherthing, "bar"); #endif where __LP64__ was erroneously thought to determine whether time_t was 64-bit. You cannot replace this with something like the following C++11 construct, though: constexpr bool time_t_64bit = sizeof(time_t) == 8; if (time_t_64bit) static_assert(true, "time_t is OK"); else static_assert(false, "time_t is bad"); because both static assertions will be evaluated at compile time, and one of them will fail. In any case, Eric Fiselier already had some sort of patch lined up, but I slacked off on trying it out. Sorry about that. :) -Dimitry
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:12 UTC