Variable-length messages.

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Oct 23 05:19:42 AEST 1988


In article <LJZ.88Oct20131114%fxgrp.fx.com at ames.arc.nasa.gov> ljz%fxgrp.fx.com at ames.arc.nasa.gov (Lloyd Zusman) writes:
>Is it really a no-no to use the 'msgBody[1]' construct as defined above?

Well, it's like this.  It is not a practical problem on an architecture
that provides a single, uniform, flat data address space.  However, on
other architectures it could fail to work, because the compiler is
entitled to assume that there is no data to be referenced beyond the
bounds of the structure and it could therefore generate code that will
fail when such an access is attempted.  I won't bore you with details.

Most programmers would probably make that structure member a pointer to
malloc()ed storage, which introduces slightly more overhead but has the
virtue of being portable.



More information about the Comp.lang.c mailing list