xref: /PHP-8.1/ext/ffi/tests/024.phpt (revision bd9f4fa6)
1--TEST--
2FFI 024: anonymous struct/union
3--EXTENSIONS--
4ffi
5--INI--
6ffi.enable=1
7--FILE--
8<?php
9    $p = FFI::new("
10    struct {
11        int a;
12        struct {
13            int b;
14            int c;
15        };
16        union {
17            int d;
18            uint32_t e;
19        };
20        int f;
21    }");
22    var_dump(FFI::sizeof($p));
23    $p->a = 1;
24    $p->b = 2;
25    $p->c = 3;
26    $p->d = 4;
27    $p->f = 5;
28    var_dump($p);
29?>
30--EXPECTF--
31int(20)
32object(FFI\CData:struct <anonymous>)#%d (6) {
33  ["a"]=>
34  int(1)
35  ["b"]=>
36  int(2)
37  ["c"]=>
38  int(3)
39  ["d"]=>
40  int(4)
41  ["e"]=>
42  int(4)
43  ["f"]=>
44  int(5)
45}
46