Re: ANSI requirement

[email protected] (Aaron Crane)
Newsgroups perl.perl5.porters
Message-ID <[email protected]>
Zefram <[email protected]> wrote:
> the struct hack does not have the same dubiousness
> as the other things mentioned, such as assuming twos complement.
> Not only does the struct hack in practice work everywhere, but AFAIK
> no one has ever established hypothetical semantics for a compiler that
> would conform to the C standard but on which the struct hack would
> not work.

FWIW, I agree entirely; apologies if what I said seemed to be a
suggestion that we shouldn't rely on the struct hack.  It's clearly
portable in practice, and I've unhesitatingly used it in the past.

>Aaron Crane wrote:
>>                                      If someone were interested, I
>>think a little configure probing and preprocessor macrology could
>>arrange for C99-capable compilers to use flexible array members in
>>place of the struct hack in the Perl source.
>
> More fuss than it's worth.  If you can't rely on the flexible array
> feature, you might as well just use the struct hack exclusively.
> It's never going to not work.

I think the big advantage of flexible array members is that the
structure type is incomplete, so we'd get compilation errors from
C99-capable smokers in the face of certain sorts of misuse of the
structures in question.  But it's certainly not an itch I want to
scratch; and there's also the issue that those sorts of misuse just
aren't very likely to happen in practice, so the real benefit would
indeed be minimal.

-- 
Aaron Crane ** http://aaroncrane.co.uk/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.