(j3.2006) Question about formal parameter dv of CFI_establish
Daniel C Chen
cdchen
Thu Jul 11 15:34:28 EDT 2013
Hello ,
In the C-interop TS, it says the following about the formal parameter dv of
CFI_establish:
dv shall be the address of a C object large enough to hold a C descriptor
of the rank specied by rank. It shall
not have the same value as either a C formal parameter that corresponds to
a Fortran actual argument or
a C actual argument that corresponds to a Fortran dummy argument. It shall
not be the address of a C
descriptor that describes an allocated allocatable object.
Q1: is the following test case legal? (it seems now according to the
wording quoted at the above).
void func(CFI_cdesc_t *target)
{
int ind;
CFI_index t lower_bounds[CFI_MAX_RANK] = {0};
CFI_CDESC_T(CFI_MAX_RANK) p;
CFI_cdesc_t *cp = (CFI_cdesc_t *) &p;
fortran_foo(cp); /*cp is passed as an actual argument that corresponds
to a Fortran dummy argument.*/
ind = CFI_establish(cp, NULL, CFI_attribute_pointer, target->type,
target->elem_len, target->rank, NULL);
}
Q2: is the following code fragment legal? (The 2nd CFI_establish seems
fine to me, but does it violate the wording quoted at the above?)
void func(CFI_cdesc_t *target)
{
int ind;
CFI_index t lower_bounds[CFI_MAX_RANK] = {0};
CFI_CDESC_T(CFI_MAX_RANK) p;
CFI_cdesc_t *cp = (CFI_cdesc_t *) &p;
ind = CFI_establish(cp, NULL, CFI_attribute_pointer, target->type,
target->elem_len, target->rank, NULL);
fortran_foo(cp); /*cp is passed as an actual argument that corresponds
to a Fortran dummy argument. after it is established.*/
ind = CFI_establish(cp, NULL, CFI_attribute_pointer, target->type,
target->elem_len, target->rank, NULL); /*can it be established again?*/
}
Thanks,
Daniel
XL Fortran Development - IBM Toronto Software Lab
Phone: 905-413-3056
Tie: 969-3056
Email: cdchen at ca.ibm.com
http://www.ibm.com/software/awdtools/fortran/xlfortran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20130711/432cf56b/attachment.html
More information about the J3
mailing list