1,888 questions
Best practices
2
votes
20
replies
355
views
Get a value of non-default-constructible type `T` from a byte array without undefined behavior
I'm messing with FFI between Rust and C++ and I happen to know that some particular array of bytes pointed by a std::byte * pointer is a valid C++ object of type T, which can be anything for what ...
0
votes
0
answers
35
views
Torch c++ binding cordump with torch c++ extension binding
I found torch-text is archived, and I still want to use it ,because there is a course that uses it. but Since it was archived, I always meet signture missing problem, so I want to fork and fix it for ...
Best practices
2
votes
16
replies
312
views
C++ references in `extern "C"`
I have a C++ function
void foo(quz::Bar &s);
I want to expose this as a C function. Originally I was doing this for FFI, and calling foo from another language (compiles to scheme). So I wrapped ...
Advice
0
votes
17
replies
98
views
Micropython: How to find the callback created with python in ffi from my C++ function?
I want to async not only call the cpp functions in Python but return Python functions in my cpp functions to make callbacks.
Example
python script
import ffi
import exemplecpp
def hello():
print(...
0
votes
1
answer
96
views
Why I am unable to load the generated .dll via wine?
I am trying to cross-compile Dart with an FFI library using mingw.
For the library I am using CMake (CMakeLists.txt):
cmake_minimum_required(VERSION 3.10)
project(HelloWorld C)
# 1. Create the ...
0
votes
1
answer
102
views
How to create a C array from a list?
I have a list of Vector2 that I want to pass to this function:
void DrawLineStrip(const Vector2 *points, int pointCount, Color color);
There is a function _array/list which looks promising, as "...
0
votes
0
answers
68
views
How to import a C define into racket via ffi?
raylib.h has the following definition:
#define RAYWHITE CLITERAL(Color){ 245, 245, 245, 255 }
How can I import this definition so that I can use RAYWHITE?
3
votes
1
answer
133
views
How to import a Haskell function in Python
I cannot fix this error. build.sh is trying to create a shared library but it fails:
~/Desktop/deepseek$ ./build.sh
Building Haskell shared library...
Loaded package environment from /home/success/....
Tooling
0
votes
1
replies
65
views
Create a runtime location for a dynamic library using the nim FFI
Is it possible to define the dynamic library location for an FFI at runtime?
I have successfully generated an FFI for SFCGAL using toast in the nim programming context, but struggled a bit with the ...
Advice
1
vote
1
replies
140
views
Is it possible to embed a Ruby interpreter in a Flutter app?
I see that it is supposed to be possible to embed a Python interpreter in a Flutter app, so can I assume it should therefore also be possible to do this with a Ruby interpreter? (I would be happy ...
4
votes
1
answer
196
views
How to pass array from Rust to FFI and free the memory properly
I want to pass byte array to FFI in Rust.
The allocation and deallocation should all be done in Rust.
Here is my implementation.
#[unsafe(no_mangle)]
pub extern "C" fn get_data(ptr: *mut *...
3
votes
1
answer
255
views
Java FFM - Unexpected behavior with "pointers" [duplicate]
To try out the Java 25 FFM API, I wanted to call C++ code through a C wrapper.
To do that, I created a small C++ class and a C wrapper following an example from here.
Printer.h
#pragma once
#include &...
0
votes
0
answers
43
views
When do i have to use guile dynamic wind functions in a C written library
I wanted to write a library in C to then link into Guile and in it i have to deal with strings. In the Guile manual the scm_to_locale_string() function has the following documentation:
Returns a C ...
0
votes
1
answer
63
views
Convert Vect AnyPtr to C Array (AnyPtr) in Idris 2
I am writing bindings for the Z3 solver library for Idris, but have gotten stuck because I can't seem to find a way to pass a Vect AnyPtr to a Z3 function (in this case, Z3_mk_and with signature ...
0
votes
1
answer
45
views
How to get printer names using koffi and WinApi function EnumPrintersW?
How to read printerStruct.pPrinterName using koffi?
const koffi = require('koffi');
const winspool = koffi.load('winspool.drv');
const kernel32 = koffi.load('kernel32.dll');
const PRINTER_ENUM_LOCAL ...