ffi

Call Windows SetWinEventHook from nodejs

时光怂恿深爱的人放手 提交于 2019-12-24 08:01:58
问题 I'm trying to call SetWinEventHook as described here for C# but from nodejs. I'm using ffi-napi to bind to the function. Here's my code so far: const ffi = require("ffi-napi") const user32 = ffi.Library("user32", { SetWinEventHook: ["int", ["int", "int", "pointer", "pointer", "int", "int", "int"]] }) const pfnWinEventProc = ffi.Callback("void", ["pointer", "int", "pointer", "long", "long", "int", "int"], function (hWinEventHook, event, hwnd, idObject, idChild, idEventThread, dwmsEventTime) {

Calling a CUDA “Hello World” from Haskell using the FFI gives wrong results

╄→гoц情女王★ 提交于 2019-12-24 04:02:20
问题 This is the standard Hello World CUDA file: #include <stdio.h> #include "hello.h" const int N = 7; const int blocksize = 7; __global__ void hello_kernel(char *a, int *b) { a[threadIdx.x] += b[threadIdx.x]; } #define cudaCheckError() { \ cudaError_t e=cudaGetLastError(); \ if(e!=cudaSuccess) { \ printf("Cuda failure %s:%d: '%s'\n",__FILE__,__LINE__,cudaGetErrorString(e)); \ exit(0); \ } \ } void hello() { char a[N] = "Hello "; int b[N] = {15, 10, 6, 0, -11, 1, 0}; char *ad; int *bd; const int

Calling a CUDA “Hello World” from Haskell using the FFI gives wrong results

一曲冷凌霜 提交于 2019-12-24 04:01:05
问题 This is the standard Hello World CUDA file: #include <stdio.h> #include "hello.h" const int N = 7; const int blocksize = 7; __global__ void hello_kernel(char *a, int *b) { a[threadIdx.x] += b[threadIdx.x]; } #define cudaCheckError() { \ cudaError_t e=cudaGetLastError(); \ if(e!=cudaSuccess) { \ printf("Cuda failure %s:%d: '%s'\n",__FILE__,__LINE__,cudaGetErrorString(e)); \ exit(0); \ } \ } void hello() { char a[N] = "Hello "; int b[N] = {15, 10, 6, 0, -11, 1, 0}; char *ad; int *bd; const int

Using c2hs on Windows

人走茶凉 提交于 2019-12-24 03:26:42
问题 I'm trying to use the libxml-enumerator package on Windows, which (ultimately) needs to use c2hs. When trying to build the relevant package, I get the seemingly infamous "does not exist" error from c2hs. This seems to be related to not having GCC installed, but this seems a list strange, since I've added Haskell's copy of gcc.exe to my path. Does anyone know how to defeat this bug? 回答1: Turns out the answer is to install MinGW by itself and not rely on the MinGW included with GHC. Hope this

Common lisp, CFFI, and instantiating c structs

巧了我就是萌 提交于 2019-12-23 18:29:09
问题 I've been on google for about, oh, 3 hours looking for a solution to this "problem." I'm trying to figure out how to instantiate a C structure in lisp using CFFI. I have a struct in c: struct cpVect{cpFloat x,y;} Simple right? I have auto-generated CFFI bindings (swig, I think) to this struct: (cffi:defcstruct #.(chipmunk-lispify "cpVect" 'classname) (#.(chipmunk-lispify "x" 'slotname) :double) (#.(chipmunk-lispify "y" 'slotname) :double)) This generates a struct "VECT" with slots :X and :Y,

Error installing ffi

落爺英雄遲暮 提交于 2019-12-23 18:00:25
问题 Can seem to get around this. $gem install ffi Building native extensions. This could take a while... ERROR: Error installing ffi: ERROR: Failed to build gem native extension. /remote/part/usern/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb checking for ffi.h... no checking for ffi.h in /usr/local/include,/usr/include/ffi... no checking for rb_thread_blocking_region()... yes checking for rb_thread_call_with_gvl()... yes checking for rb_thread_call_without_gvl()... yes checking for ffi_prep

Is it possible to call into C functions from OCaml, without wrapped types?

扶醉桌前 提交于 2019-12-23 16:26:41
问题 I'm trying to write a (desperately tiny, simple — I have no idea what I'm doing, let's be real!) compiler in OCaml. I'd really like to avoid checking any ISO-C code into the project (despite knowing C fairly well; the goal here is to learn and use OCaml exclusively.) Pursuant to this, I need to write a “runtime” for the compiled language in OCaml, compile it separately from the primary project, and then link it against the compiler-itself's output. Unfortunately, it looks like any external

Is it possible to call a Rust function taking a Vec from C?

拈花ヽ惹草 提交于 2019-12-23 15:53:17
问题 Suppose I have the following Rust library: // lib.rs #![crate_type = staticlib] #[no_mangle] pub extern fn do_something(number: i32) { // something } #[no_mangle] pub extern fn do_something_else(collection: &Vec<i32>) { // something } I know that, to call do_something from C, I'd just need to declare an extern function taking an int32_t , but is it possible to call do_something_else ? If so, how? 回答1: You can , but the better question is should you? Since you cannot construct a Vec from C,

How to store a reference without having to deal with lifetimes?

允我心安 提交于 2019-12-23 15:38:47
问题 As suggested by the dynamic_reload crate's example, I collected Symbol s instead of extracting them every time, but Symbol requires a lifetime. Using a lifetime changes method signatures and breaks the compatibility with method DynamicReload::update . Is it a valid workaround to use std::mem::transmute to change Symbol 's lifetime to 'static ? extern crate dynamic_reload; use dynamic_reload::{DynamicReload, Lib, Symbol, Search, PlatformName, UpdateState}; use std::sync::Arc; use std::time:

How to extend JS class in ReasonML

佐手、 提交于 2019-12-23 12:28:52
问题 For example, I have an es6 -like class: class Foo {...} And I want to extend it: class Bar extends Foo {...} In reason-react documentation I found examples, but I'm not sure that it's appropriate for me: let component = ReasonReact.reducerComponent "TodoAppRe"; let make _children => { ...component, initialState: fun () => {count: 0}, <...> But when i try to write code in this style, i get an error: let myclass unit => { ...mysuperclass, hello: fun () => { Js.log "FooBar"; } }; Error: Unbound