-
-
Save vaind/2ffd8c8bde7e2d0bd1fc9559cbdfb3be to your computer and use it in GitHub Desktop.
flutter AOT precompiler error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:ffi'; | |
// FFI signature | |
typedef _dart_memset = void Function(Pointer<Uint8>, int, int); | |
typedef _c_memset = Void Function(Pointer<Uint8>, Int32, IntPtr); | |
_dart_memset? fbMemset; | |
void _fallbackMemset(Pointer<Uint8> ptr, int byte, int size) { | |
final bytes = ptr.cast<Uint8>(); | |
for (var i = 0; i < size; i++) { | |
bytes[i] = byte; | |
} | |
} | |
void main() { | |
try { | |
fbMemset = DynamicLibrary.process() | |
.lookupFunction<_c_memset, _dart_memset>('memset'); | |
} catch (_) { | |
// This works: | |
// fbMemset = _fallbackMemset; | |
// This doesn't: /aot/precompiler.cc: 2761: error: unreachable code | |
fbMemset = (Pointer<Uint8> ptr, int byte, int size) { | |
final bytes = ptr.cast<Uint8>(); | |
for (var i = 0; i < size; i++) { | |
bytes[i] = byte; | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment