Re: "character (len = :), allocatable :: foo" ?
From: Jugoslav Dujic (jdujicREMOVE_at_uns.ns.ac.yu)
Date: 11/06/03
- Next message: boray: "F77 to F90 Converter needed."
- Previous message: Clive Page: "Re: Select Case Statement"
- In reply to: Richard Maine: "Re: "character (len = :), allocatable :: foo" ?"
- Next in thread: Richard Maine: "Re: "character (len = :), allocatable :: foo" ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 6 Nov 2003 10:42:01 +0100
Richard Maine wrote:
| ajpspragg@rhmtech.co.uk (Andy Spragg) writes:
|
|| On Wed, 5 Nov 2003 17:37:46 +0100, "Jugoslav Dujic"
|| <jdujicREMOVE@uns.ns.ac.yu> wrote:
|
||| character, allocatable :: foo (:)
||| and
||| character (len = :), allocatable :: foo
||| is/will be indeed different...
||
|| Eek! Does this mean that it is not possible for me properly to use a
|| stdcall with a pointer to char argument unless I know in advance how
|| long it needs to be? Could this be the source of my stack inflation?
|
| Character argument passing is...interesting, particularly in
| mixed language environments. I know nothing about Microsoft
| calling conventions (stdcall vs whatever that other one was).
OK, just FYI, here's a summary of stdcall vs. cdecl calling conventions.
Stdcall is also known as PASCAL, but that term is deprecated. Cdecl is
classic C calling convention used on Unix. Stdcall differs in the following
aspects:
1) It's the duty of called routine to clean the stack. In cdecl, caller
cleans the stack (returns the stack pointer to the value before the call).
2) Name mangling is different. In stdcall, it's always
_routinename@nargs4
where nargs4 is 4*number of arguments = number of bytes pushed on the
stack.
I think both implementations use left-to-right argument pushing (I think
old PASCAL flavor used right-to-left). Also, by default, scalars are
passed by value, and arrays & strings by reference in both conventions.
Stdcall is tad (one or two cycles) faster and produces slightly smaller
code (calls cleaning is in one place per routine).
The Good Thing about it is that it doesn't allow mismatch in number of
arguments (name mangling will cause a linker error -- even if not, stack
will be screwed badly as the callee would free more arguments than the
caller has sent). It's also a bad thing for porting old codes which
used argument count mismatch deliberately (e.g. map a string argument
to a BYTE array).
-- Jugoslav ___________ www.geocities.com/jdujic
- Next message: boray: "F77 to F90 Converter needed."
- Previous message: Clive Page: "Re: Select Case Statement"
- In reply to: Richard Maine: "Re: "character (len = :), allocatable :: foo" ?"
- Next in thread: Richard Maine: "Re: "character (len = :), allocatable :: foo" ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|