www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/13/06:11:23

From: combee AT cambridge DOT scr DOT slb DOT com (Leendert Combee)
Message-Id: <199701131043.KAA01153@tartan.scr.slb.com>
Subject: Re: f2c+djgpp
To: glynnec AT ix DOT netcom DOT com (Glynne Casteel)
Date: Mon, 13 Jan 1997 10:43:37 +0000 (GMT)
Cc: djgpp AT delorie DOT com
In-Reply-To: <5bbbeq$h8@dfw-ixnews12.ix.netcom.com> from "Glynne Casteel" at Jan 12, 97 06:44:42 pm
Mime-Version: 1.0

> This is no cause for concern; a does not need to be reset!  The reason
> is that it is passed in as a pointer to the function.  Something like
> [I assume]: 
> 
>    void test( double *a, int n )
>    {
>     /* decrementing a here has no effect on its value 
>      * in the calling program!!
>      */
>     a--;  /* calling program cannot see this */
> 
>     /* HOWEVER changing the values that it points to 
>      * will be reflected in the calling program
>      */
>     a[1] = 16.0;   /* calling program CAN see this change */
> 
>    }
> 

  No!, on return a[i] correspond now to a[i+1] before the function was called
  (+whatever happened in the function). Because a (not *a) is a pointer, 
  --a changes that value!  The code generated by f2c shoudl really use
  a_new-- = a ; and then work with a_new rather than a. This causes that
  a[i] still points to same element of a before _and_after the function
  call !!

  Leendert

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019