211. A simple derived type with the BIND(C) attribute interoperates with a C struct.#
topic: Interoperability with C and C++
Note
This tip is a draft1.
Use the bind(c) attribute to make a derived type compatible with C, with restrictions listed at
Use the bind(c) attribute to make a derived type compatible with C, with restrictions listed at https://t.co/P7PbDVsc9a. For example,
— FortranTip (@fortrantip) May 6, 2022
type, bind(c) :: date
integer (kind=c_int) :: year, month
end type
interoperates with
typedef struct {
int year, month;
} date;
- 1
From the perspective of FortranTip Browser, “draft” means that it hasn’t been edited for formatting, hasn’t had corresponding Fortran programs added, the text content hasn’t been enhanced, etc. Draft texts are extracted from the corresponding Tweet using the Twitter API.