Re: Pointers to functions: Is this the right [f03] syntax?




Richard E Maine wrote:
Andy <andyv@xxxxxxxxxxxxxx> wrote:

I've made a couple fixes and the current g95 can compile and run this
code fine now. I am worried that things may be a little too loose in
that the pointer p in the original code points to a subroutine, then
later on a function,

I don't see that in the code posted here, though I suppose it might be
so in the prior posting to gg95 (I don't often read that group).

It looked something like:

module m
contains
subroutine sub
print *, 'in sub'
end subroutine sub

function func()
func = 1.0
end function func
end module m

use m
procedure (), pointer :: p

p => sub
call p()

p => func
print *, p()
end

.



Relevant Pages

  • Re: explain the result
    ... No, func is *not* a pointer to the function, it is the function. ... A _function designator_ is an expression that has function type. ... Because this conversion does not occur, the operand of the sizeof ...
    (comp.lang.c)
  • Re: Passing function pointers as arrays of chars
    ... memcpy(func_addr, &func, sizeof func); ... pointer needs not to be meaningful? ... and &func is a pointer to a function pointer object. ...
    (comp.lang.c)
  • Re: Passing function pointers as arrays of chars
    ... memcpy(func_addr, &func, sizeof func); ... pointer needs not to be meaningful? ... char object, and &func is a pointer to a function pointer object. ...
    (comp.lang.c)
  • Re: Finding the callstack programmatically
    ... > Ashutosh wrote: ... > the address 485bb lies between func and main, ... > is func(the body of the func lies between the func pointer and the main ...
    (comp.unix.programmer)
  • Re: Finding the callstack programmatically
    ... > Ashutosh wrote: ... > the address 485bb lies between func and main, ... > is func(the body of the func lies between the func pointer and the main ...
    (comp.unix.programmer)