# Binding multiple C functions under one Fortran interface

**URL:** <https://fortran-lang.discourse.group/t/binding-multiple-c-functions-under-one-fortran-interface/9457>\
**Category:** Uncategorized\
**Created:** [March 23, 2025, 10:22am UTC](https://fortran-lang.discourse.group/t/binding-multiple-c-functions-under-one-fortran-interface/9457 "2025-03-23T10:22:23Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [March 23, 2025, 2:22pm UTC](https://fortran-lang.discourse.group/t/binding-multiple-c-functions-under-one-fortran-interface/9457/9 "2025-03-23T14:22:10Z")

</div>

It looks like generic procedure resolution is strict in terms of satisfying the TKR rule:

> A dummy argument is type, kind, and rank compatible, or TKR compatible, with another dummy argument if the first is type compatible with the second, the kind type parameters of the first have the same values as the corresponding kind type parameters of the second, and both have the same rank or either is assumed-rank.

This rule is violated when you call the routine via the generic name `form` instead of the specific name `form1`.

Besides the solution of @FedericoPerini which creates a copy of the string, you could also do the following:

```auto
character(kind=c_char,len=40), target :: label

label = "abracadabra"//c_null_char
call form1(label) ! sequence association

block
    character(c_char), pointer :: p_label(:) => null()

    ! Fortran len_trim() includes the termination character
    ! C strlen() does not include the termination character

    call c_f_pointer(c_loc(label),p_label,[len_trim(label)])
    call form( p_label ) ! generic resolution to form1
end block

```

---

_[View the full topic](https://fortran-lang.discourse.group/t/binding-multiple-c-functions-under-one-fortran-interface/9457)._
