public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: burlen <burlen.loring@gmail.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: fortran 90 passing user defined type member to a c fucntion
Date: Sun, 28 Mar 2010 07:29:00 -0000	[thread overview]
Message-ID: <mcrsk7lpo1o.fsf@dhcp-172-17-9-151.mtv.corp.google.com> (raw)
In-Reply-To: <4BAE42FF.7020200@gmail.com> (burlen's message of "Sat\, 27 Mar 2010 10\:40\:15 -0700")

burlen <burlen.loring@gmail.com> writes:

> Ian Lance Taylor wrote:
>> burlen <burlen.loring@gmail.com> writes:
>>
>>   
>>> When calling a c function from a fortran 90 program with members of a
>>> user defined types for output arguments of the called subroutine the
>>> user defined types aren't being modified as they should be (according
>>> to my understanding).
>>>     
>>
>> When you call a C function, you get the C rules.  It doesn't matter
>> whether you are calling it from Fortran or not.  In C, a modification
>> of an argument is not reflected back to the caller.
>>
>> Ian
>>   
> In my understanding, Fortran unless otherwise instructed is supposed
> to pass by address. In the c function modifying the data pointed to
> should do just that, and be visible to the caller. What I don't
> understand is why passing the member of a user defined type behaves as
> if it's passed by value in this case, while passing the corresponding
> native type is passed by address and works as expected.


I think you are going to have to provide an example.


If you write a C function

void foo(int i) { i = 1; }

then the parameter is not going to change in the caller.  That's just
how C works.  There is no reasonable way to change that.

Ian

  reply	other threads:[~2010-03-27 19:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-26 22:02 burlen
2010-03-27  6:28 ` Ian Lance Taylor
2010-03-28  3:12   ` burlen
2010-03-28  7:29     ` Ian Lance Taylor [this message]
2010-03-28 20:22       ` burlen
2010-03-28 20:52     ` Tim Prince

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mcrsk7lpo1o.fsf@dhcp-172-17-9-151.mtv.corp.google.com \
    --to=iant@google.com \
    --cc=burlen.loring@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).