024.phpt 613 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. FFI 024: anonymous struct/union
  3. --EXTENSIONS--
  4. ffi
  5. --INI--
  6. ffi.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--
  31. int(20)
  32. object(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. }