Re: Direct access and derived types.



Joost <jv244@xxxxxxxxx> wrote:

Changing the order of the components can also change things here. Again,
that is not guaranteed by the standard. I would be extremely reluctant
to write code whose correct working depends on the order of the
components. That implies a nonstandard assumption, and one that might
cause the code to break with a new version of the compiler or different
compiler switches.

I assume that the BIND(C) F2003 attribute could help to get a 'kind of
portable' layout of derived types ? Since a few compilers already
support this, this could be an option as well.

Perhaps, but... I'm not sure that C guarantees the layout and padding in
all cases either, probably for the same reason that Fortran doesn't.
After all, the underlying issue is a hardware one, which isn't going to
just go away by switching languages. C, being aimed at a "lower level",
might give you more control of the options than Fortran does, but I'm
not sure that you can do completely arbitrary things with the layout and
expect them to work without padding.

I'm not that much of a C expert, so I could be wrong on all this.

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
.



Relevant Pages

  • Re: SEQUENCE
    ... efficient order, these must interoperate with the Windows API, so they ... trying to make the compiler generate compatible padding. ... you are using Intel Fortran The Intel Fortran ... When I specified SEQUENCE as occurs in other API structures, I couldn't get the compiler to add the 3 padding bytes. ...
    (comp.lang.fortran)
  • Re: Structure padding.
    ... >I need to fill in the size of padding array here so as to ... still do it by generating the declaration at runtime, ... the compiler" -- which should be true unless you wait too long (so ... internal C structure layout meet some external file format -- which ...
    (comp.lang.c)
  • Re: A question on Newtons Method
    ... >> I can't believe you'd advise a noob to use a compiler which is still ... > production codes and codes from textbooks. ... > The Fortran standard generally does not specify the required behavior ... >> another important class of hassle which most numerical programmers ...
    (sci.math.num-analysis)
  • Fortran Resources (July 2004)
    ... and the standard for the Fortran language and its derivatives. ... WHERE CAN I OBTAIN A FORTRAN 95 COMPILER? ... Absoft Fortran compilers, debuggers, and development tools for Windows, ... are available for Linux systems. ...
    (comp.lang.fortran)
  • Fortran Resources (August 2004)
    ... and the standard for the Fortran language and its derivatives. ... Absoft Fortran compilers, debuggers, and development tools for Windows, ... and Linux include source-compatible Fortran 95 compiler suites ... are available for Linux systems. ...
    (comp.lang.fortran)