xref: /php-src/ext/ffi/tests/gh11934b.phpt (revision 0b9702c9)
1--TEST--
2Feature GH-11934 (Allow to pass CData into C variables)
3--EXTENSIONS--
4ffi
5zend_test
6--FILE--
7<?php
8require_once __DIR__ . '/utils.inc';
9$header = <<<HEADER
10extern int gh11934b_ffi_var_test_cdata;
11HEADER;
12
13if (PHP_OS_FAMILY !== 'Windows') {
14    $ffi = FFI::cdef($header);
15} else {
16    try {
17        $ffi = FFI::cdef($header, 'php_zend_test.dll');
18    } catch (FFI\Exception $ex) {
19        $ffi = FFI::cdef($header, ffi_get_php_dll_name());
20    }
21}
22
23$ffi->gh11934b_ffi_var_test_cdata->cdata = 2;
24var_dump($ffi->gh11934b_ffi_var_test_cdata);
25$source = $ffi->new('int');
26$source->cdata = 31;
27$ffi->gh11934b_ffi_var_test_cdata = $source;
28var_dump($ffi->gh11934b_ffi_var_test_cdata);
29
30?>
31--EXPECT--
32int(2)
33int(31)
34