Ffi pack: C99 bool processing

What should be used for the C99 bool type? I tried the following but it fails:

C declaration:

bool Filter_Max_uint8 (uint8_t response[], const uint8_t data[], size_t temp[], size_t size, size_t order);

Prolog:

:- c_import("#include \"Filter.h\"",                  % ffi:cpp_hook provides -I flag
            [ linasm(lib/'liblinasm.so') ],
	    [
	      'Filter_Max_uint8'(  *int,       % uint8_t response[],
	                           *int,       % const uint8_t data[],
				               *int,       % size_t temp[],
				               int,        % size_t size,
				               int,        % size_t order,
			                   [int])
	    ]).

The error is:

ERROR: /tmp/prolog/linasm/filter.pl:11:
ERROR:    FFI: 'Filter_Max_uint8': incompatible return type: int <- '_Bool'

For those that stumble upon this thread, this is fixed in the latest version of the ffi pack.

1 Like