Re: ISO_C_BINDING and arrays, optional arguments, etc.



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.
.



Relevant Pages

  • [PATCH] drivers/block/DAC960: Converted boolean to bool
    ... Converts 'boolean' to 'bool' and removes the 'boolean' typedef. ... unsigned char CommandOpcode2, ... typedef struct DAC960_SCSI_RequestSense ...
    (Linux-Kernel)
  • [PATCH] drivers/video/sis: Convert to generic boolean
    ... BOOLEAN -> bool ... Have followed all function/variable paths who been converted to 'bool' ... SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay, ...
    (Linux-Kernel)
  • Re: Weird problem calling DLL
    ... afaik a Delphi boolean is not ... always equal to a bool also. ... *neither* language defines the binary representation of the types. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Code review requested
    ... I'm perfectly happy to use a 'bool' variable to ... take boolean parameters or that have boolean return values. ... If the 'bool' type is replaced with 'int', ... expect when searching a list verses sorting a list. ...
    (comp.lang.c)
  • Re: More than a style issue?
    ... The bool type is used to represent Boolean values: ... some would consider a missing feature). ... falling through to the next) for nothing more than the sake of clarity ...
    (microsoft.public.dotnet.languages.csharp)