Nick Bowler wrote (on Thu 20-Jun-2013 at 21:45 +0100): .... > I would only add the extra types if you actually encounter an > implementation where it matters. Feel free to add an intmax_t > member to the union as well (after checking for its existence). The problem I have is that where "it matters" the program would happily build, but fall over in obscure ways at run-time on some distant system which happens to be running something out of the ordinary. ... > 3) Don't let the perfect be the enemy of the good enough. Something which failed at build-time would indeed be "good enough". ... > Unfortunately, it's likely the best you can do without something > like max_align_t, or __BIGGEST_ALIGNMENT__, or whatever. What I was hoping for was help from Autoconf in identifying where one of these mechanisms was available. If many/most compilers provide, say, __BIGGEST_ALIGNMENT__ but some have a different name for it, then that seems to me something that Autoconf could/should help with. Where no such mechanism is available, then a compile time error would tell everybody that some extra work is required... perhaps a -Dbar for building in some (obscure) environment. > > Actually, for what I am trying to do, I have decided to fake > > alignof(). It takes a bit of dicking-about, but it occurred to me > > that alignof(foo_t) may be constructed as offsetof(struct { char > > x; foo_t q; }, q)... Sadly gcc throws an unhelpful (in this case) > > warning... which requires some scrubbing around :-( > This pattern is essentially the same as how AC_CHECK_ALIGNOF > actually works. There is also an alignof module in Gnulib > which may be of interest to you. Thanks. Happy to see the trick is generally agreed to work :-) It throws an "anonymous struct declared inside parameter list [enabled by default]" warning, though :-( > But I'm not sure this (by itself) helps you, since you'd still need > a suitable definition of foo_t. I'm allocating memory for various types en masse. So I malloc enough for some general red-tape followed by a bunch of items of foo_t -- for various foo_t. My first thought was to ensure that the red-tape was __BIGGEST_ALIGNMENT__ aligned. My second thought was to align sizeof(foo_t) % __BIGGEST_ALIGNMENT__ where that isn't zero. My third thought was alignof(foo_t). Thanks, Chris _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx https://lists.gnu.org/mailman/listinfo/autoconf