"Richard Maine" <nos...@see.signature> wrote in message
news:1kfruq4.ngzh4e5fh49kN%nos...@see.signature...
> And indeed it is quite plausible that there could be compiler switches
> to specify which of multiple possible companion processors bind(C) is to
> be interoperable with. It's been a while now and the memory of that
> specific detail is a little hazy, but I'm fairly sure that was in
> people's minds when writing the f2003 interoperability spec. I'm 100%
> sure that the subject of multiple conventions on the same platform came
> up. I think that the conclusion was that this could be handled by
> compiler switches, though I'm less sure about recalling that part.
However on Linux both ifort and gfortran are documented as being
interoperable with gcc. I thought maybe the O.P. was using an old
version of ifort but Steve Lionel's post to the companion thread
in Intel's forum leads me to believe that this is not the case and
ifort likely has a bug here.
I think multiple conventions could be handled by compiler switches
but it's not implemented that way in either ifort or gfortran.
The problem lies in STDCALL interfaces to invoke Win32 API functions
or create callbacks for such functions. ifort doesn't let you mix
BIND(C) with STDCALL and gfortran has a switch -mrtd that works but
the compiler then goes ahead and generates STDCALL interfaces to
even library functions even though their interface should be
explicit to the compiler and gfortran doesn't have STDCALL library
function to invoke :(
On ifort you have to use their !DEC$ ATTRIBUTES STDCALL extension
and gfortran only works in a reasonable way if you use their
!gcc$ ATTRIBUTES STDCALL extension. Switches would be much nicer
because you could use the same source code for both without
markup like C code would use.
Functions that return user-defined types are a particular sore
point in that on 32-bit Windows the reasonable standard for anyone
to follow is Microsoft Visual C and ifort is documented as being
interoperable but gcc, hence gfortran, have an incompatibility in
that for structures that can't be returned in registers, both
MSVC++ and gcc demand a hidden first argument that is a pointer
to storage for the result variable, but gcc pops that pointer off
the stack on return whereas MSVC++ doesn't! Now, a defensively
written (in assembly language) caller can ensure that neither
behavior causes problems but you can't create guard code like
this in high level language. Really, the MinGW people should
consider this incompatibility a bug and fix it (it's not a
problem in 64-bit Windows where everyone is more civilized and
use the same calling convention.)
For more about various calling conventions, I highly recommend
Agner Fog's
http://www.agner.org/optimize/calling_conventions.pdf
--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end