Re: ISO_C_BINDING and arrays, optional arguments, etc.
- From: "FX" <coudert@xxxxxxxxxxxxx>
- Date: Fri, 4 Feb 2011 09:23:12 +0000 (UTC)
Never do this, because no Fortran variable type is interoperable with
_Bool.
Would you care to back this affirmation up? Simple tests show that it
works nicely:
$ cat a.c
#include <stdio.h>
void foo (_Bool b)
{
printf ("Boolean is %s\n", b ? "true" : "false");
}
$ cat a.f90
use iso_c_binding
interface
subroutine foo(b) bind(c)
use iso_c_binding
logical(c_bool), value :: b
end subroutine
end interface
call foo(.true._c_bool)
call foo(.false._c_bool)
end
$ gfortran a.f90 a.c && ./a.out
Boolean is true
Boolean is false
Start with gboolean = gint = int has storage size 4 bytes, but _Bool
has storage size 1 byte.
So, what you really mean is that gboolean is not _Bool. That's quite
different from your overbroad assertion above.
.
- Follow-Ups:
- References:
- ISO_C_BINDING and arrays, optional arguments, etc.
- From: vincenzo
- Re: ISO_C_BINDING and arrays, optional arguments, etc.
- From: James Van Buskirk
- ISO_C_BINDING and arrays, optional arguments, etc.
- Prev by Date: Re: Composite assignment operators in Fortran
- Next by Date: Re: ISO_C_BINDING and arrays, optional arguments, etc.
- Previous by thread: Re: ISO_C_BINDING and arrays, optional arguments, etc.
- Next by thread: Re: ISO_C_BINDING and arrays, optional arguments, etc.
- Index(es):
Relevant Pages
|