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