xref: /PHP-8.1/ext/ffi/tests/bug79532.phpt (revision bd9f4fa6)
1--TEST--
2Bug #79532 (sizeof off_t can be wrong)
3--EXTENSIONS--
4ffi
5zend_test
6--FILE--
7<?php
8require_once('utils.inc');
9
10$header = <<<HEADER
11void bug79532(off_t *array, size_t elems);
12HEADER;
13
14if (PHP_OS_FAMILY !== 'Windows') {
15    $ffi = FFI::cdef($header);
16} else {
17    try {
18        $ffi = FFI::cdef($header, 'php_zend_test.dll');
19    } catch (FFI\Exception $ex) {
20        $ffi = FFI::cdef($header, ffi_get_php_dll_name());
21    }
22}
23
24$array = FFI::new("off_t[3]");
25$ffi->bug79532($array, 3);
26var_dump($array);
27?>
28--EXPECTF--
29object(FFI\CData:int%d_t[3])#%d (3) {
30  [0]=>
31  int(0)
32  [1]=>
33  int(1)
34  [2]=>
35  int(2)
36}
37