At 12:32 AM -0800 2/17/00, Jim Schram wrote:
>The ambiguity is whether or not the compiler will allocate for an instance of
>SomeType in an instance of MyStruct when you use this syntax, and that's highly
>compiler-dependent.
>...
>Other compilers will error and abort the compilation, or treat the [] or [0] as [1]
>which is the next semi-logical choice, with or without warning, causing seemingly
>unpredictable results which may not be caught during testing.
Thanks for the explanation. To avoid relying on the compiler (beyond it conforming to
the ANSI spec), it sounds like you should avoid unbounded or zero-length array
elements in structs.
>So in your example above, you would use OffsetOf(MyStruct, finalField) in place of
>sizeof(MyStruct) throughout your code for accurate, predictable results. "It's A Good
>Thing." -- Martha Stewart
Yup - that's what I've seen done. I was just wondering why people went through all the
trouble. It seems like the ANSI standard should define how [] works so people don't
have to jump through this particular hoop. :)
Danny
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html