Re: fortran 90 passing user defined type member to a c fucntion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



burlen <burlen.loring@xxxxxxxxx> writes:

> Ian Lance Taylor wrote:
>> burlen <burlen.loring@xxxxxxxxx> 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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux