/usr/share/doc/libcnf-dev/html/node61.html is in libcnf-dev 4.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 98.2 beta6 (August 14th, 1998)
original version by: Nikos Drakos, CBLU, University of Leeds
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>Function Values</TITLE>
<META NAME="description" CONTENT="Function Values">
<META NAME="keywords" CONTENT="sun209">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="sun209.css">
<LINK REL="next" HREF="node62.html">
<LINK REL="previous" HREF="node60.html">
<LINK REL="up" HREF="node57.html">
<LINK REL="next" HREF="node62.html">
</HEAD>
<BODY >
<BR> <HR>
<A NAME="tex2html854"
HREF="node62.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
<A NAME="tex2html852"
HREF="node57.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
<A NAME="tex2html846"
HREF="node60.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> <A HREF="sun209.html#stardoccontents"><IMG
ALIGN="BOTTOM" BORDER="0" SRC="contents_motif.gif"
ALT="252"></A>
<BR>
<B> Next:</B> <A NAME="tex2html855"
HREF="node62.html">Global Data</A>
<BR>
<B>Up:</B> <A NAME="tex2html853"
HREF="node57.html">VAX/VMS</A>
<BR>
<B> Previous:</B> <A NAME="tex2html847"
HREF="node60.html">Arguments</A>
<BR> <HR> <P>
<!--End of Navigation Panel-->
<H3><A NAME="SECTION000153400000000000000">
Function Values</A>
</H3>
<P>
The way that the return value of a function is handled is very much like a
simple assignment statement. In practice, the value is actually returned in one
or two of the registers of the CPU, depending on the size of the data type.
Consequently there is no problem in handling the value of any function that
returns a numerical value as long as the storage used by the value being
returned and the value expected correspond
(see Table <A HREF="node59.html#vms_datatypes"><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]" SRC="cross_ref_motif.gif"></A>).
If a VAX C function is treated as a <TT>LOGICAL</TT> function by VAX FORTRAN,
there is no problem as long as the VAX C function ensures that it returns a
value that will be interpreted correctly.
The best thing to do is to make sure that the C function can only return zero
(for false) or minus one (for true).
<P>
The case of a function that returns a character string is more complex. The way
that VAX FORTRAN returns a <TT>CHARACTER</TT> variable as a function value is
to add a hidden extra entry to the beginning of the argument list.
This is a pointer to
a character descriptor. If a VAX C function wishes to return a function value
that VAX FORTRAN will interpret as a character string, then you must explicitly
add an extra argument to the VAX C function and build the appropriate structure
in your C function. This may seem rather complicated, but what it boils down to
is that the following two segments of VAX FORTRAN are equivalent (but only in
VAX FORTRAN).
<P>
<A NAME="vms_charfn"></A>
<DIV ALIGN="CENTER">
Example
- Equivalence of a VMS character function and a
VMS subroutine.
</DIV>
<PRE>
CHARACTER*(10) RETURN
CALL CHARFN( RETURN, A, B )
or
CHARACTER*(10) RETURN, CHARFN
RETURN = CHARFN( A, B )
</PRE>
If written as a function, CHARFN returns a value of type <TT>CHARACTER</TT>.
It is left as an exercise for the reader to demonstrate that the above
assertion is true using just FORTRAN.
<P>
<BR> <HR>
<A NAME="tex2html854"
HREF="node62.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
<A NAME="tex2html852"
HREF="node57.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
<A NAME="tex2html846"
HREF="node60.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> <A HREF="sun209.html#stardoccontents"><IMG
ALIGN="BOTTOM" BORDER="0" SRC="contents_motif.gif"
ALT="252"></A>
<BR>
<B> Next:</B> <A NAME="tex2html855"
HREF="node62.html">Global Data</A>
<BR>
<B>Up:</B> <A NAME="tex2html853"
HREF="node57.html">VAX/VMS</A>
<BR>
<B> Previous:</B> <A NAME="tex2html847"
HREF="node60.html">Arguments</A>
<BR> <HR> <P>
<!--End of Navigation Panel-->
<ADDRESS>
<I>CNF and F77 Mixed Language Programming -- FORTRAN and C<BR>Starlink User Note 209<BR>P.M. Allan<BR>A.J. Chipperfield<BR>R.F. Warren-Smith<BR>19 January 2000<BR>E-mail:<A HREF="mailto:ussc@star.rl.ac.uk">ussc@star.rl.ac.uk</A></I>
</ADDRESS>
</BODY>
</HTML>
|