Re: busting sp datatypes



glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx> wrote:

character*7 x(10)
....
! without c_sizeof(), the 7 in the qsort call assumes
! no padding in the array. It works with g95, but I don't
! know if other compilers might add padding.

If they claim to conform to the standard, they better not. Derived types
are a different matter, but character is pretty much "tied down" in such
matters. Not worth digging out the citations.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.



Relevant Pages

  • Re: Does an array of char have alignment issues?
    ... I have no idea what you mean by "tile an array". ... padding bytes after the first char, ... after the last member, ... A union can also ...
    (comp.sys.arm)
  • Re: Question about Declare and Type
    ... Jim Carlock wrote: ... In this particular case, no padding is needed within the struct, except ... that if you declare an array of such, each element of the array will ... but one-byte characters when passed to a Declared function -- ...
    (microsoft.public.vb.general.discussion)
  • Re: Does an array of char have alignment issues?
    ... The struct will have padding bytes so that its fields are aligned. ... Yes, the usual practice is to memcpyeach member of the structure, ... sizeofincludes padding needed to tile an array ...
    (comp.sys.arm)
  • Re: Does an array of char have alignment issues?
    ... I have no idea what you mean by "tile an array". ... padding bytes after the first char, then sizeofwould be 12 because an extra 3 bytes are needed in an array to keep the array elements aligned -- pointers to the unaligned array elements would not work, at least on the ARM. ... after the last member, ... A union can also ...
    (comp.sys.arm)
  • Re: [JW] alignment problem for structures
    ... Is that enough to make the alignment requirements apply to ... Array elements include interelement ... >> alignment padding. ... to the start of the struct, then the assignment to *q1 will not "work". ...
    (comp.std.c)