]>
Commit | Line | Data |
---|---|---|
c63539ff ML |
1 | .. |
2 | Copyright 1988-2022 Free Software Foundation, Inc. | |
3 | This is part of the GCC manual. | |
4 | For copying conditions, see the copyright.rst file. | |
5 | ||
6 | .. index:: C_FUNLOC, pointer, C address of procedures | |
7 | ||
8 | .. _c_funloc: | |
9 | ||
10 | C_FUNLOC --- Obtain the C address of a procedure | |
11 | ************************************************ | |
12 | ||
13 | .. function:: C_FUNLOC(x) | |
14 | ||
15 | ``C_FUNLOC(x)`` determines the C address of the argument. | |
16 | ||
17 | :param x: | |
18 | Interoperable function or pointer to such function. | |
19 | ||
20 | :return: | |
21 | The return value is of type ``C_FUNPTR`` and contains the C address | |
22 | of the argument. | |
23 | ||
24 | Standard: | |
25 | Fortran 2003 and later | |
26 | ||
27 | Class: | |
28 | Inquiry function | |
29 | ||
30 | Syntax: | |
31 | .. code-block:: fortran | |
32 | ||
33 | RESULT = C_FUNLOC(x) | |
34 | ||
35 | Example: | |
36 | .. code-block:: fortran | |
37 | ||
38 | module x | |
39 | use iso_c_binding | |
40 | implicit none | |
41 | contains | |
42 | subroutine sub(a) bind(c) | |
43 | real(c_float) :: a | |
44 | a = sqrt(a)+5.0 | |
45 | end subroutine sub | |
46 | end module x | |
47 | program main | |
48 | use iso_c_binding | |
49 | use x | |
50 | implicit none | |
51 | interface | |
52 | subroutine my_routine(p) bind(c,name='myC_func') | |
53 | import :: c_funptr | |
54 | type(c_funptr), intent(in) :: p | |
55 | end subroutine | |
56 | end interface | |
57 | call my_routine(c_funloc(sub)) | |
58 | end program main | |
59 | ||
60 | See also: | |
61 | :ref:`C_ASSOCIATED`, | |
62 | :ref:`C_LOC`, | |
63 | :ref:`C_F_POINTER`, | |
3ed1b4ce | 64 | :ref:`C_F_PROCPOINTER` |