Main.hx 996 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. @:headerClassCode('
  2. static constexpr int64_t myInt64 = 10;
  3. ')
  4. class Test {
  5. public function new() {}
  6. public function getInt64():cpp.Int64
  7. return untyped __cpp__('myInt64');
  8. }
  9. class Main {
  10. public static function main() {
  11. var t = new Test();
  12. #if (haxe > "4.2.5") // nightly rc
  13. // 1.
  14. var other:Int = t.getInt64(); // Warning : (WDeprecated) Implicit cast from Int64 to Int (32 bits) is deprecated. Use .toInt() or explicitly cast instead.
  15. // 2. iterate implicitly truncated
  16. for (i in 0...t.getInt64()) // ERROR: cpp.Int64 should be Int
  17. trace(i);
  18. // 3. iterate explicitly truncated
  19. for (i in 0...t.getInt64().toInt()) // OK
  20. trace(i);
  21. // 4. iterate on int64-range
  22. var start:cpp.Int64 = 0;
  23. for (i in start...t.getInt64()) // ERROR: cpp.Int64 should be Int
  24. trace(i);
  25. #else // tested with 4.2.5
  26. // truncate implicitly
  27. var other:Int = t.getInt64(); // OK
  28. // iterate implicitly truncated
  29. for (i in 0...t.getInt64()) // OK
  30. trace(i);
  31. #end
  32. }
  33. }