Fortran logical boolean byte size

Fortran compilers typically use 4 bytes for logical while C compilers usually use 1 byte for bool. For C interoperability, Fortran can use:

use, intrinsic :: iso_c_binding

logical(kind=C_BOOL) :: L
integer :: Q

c_sizeof(L) == 1
c_sizeof(Q) == 4
! typically

while C uses:

#include <stdbool.h>

bool L;

sizeof(L) == 1
# typically

So as usual, use iso_c_binding when using C or C++ with Fortran modules to produce cross-platform compatible projects.

Examples

See standard/logical_kind Fortran and C examples.