ffi: fix FLOAT_32 and FLOAT_64 type constants by watilde · Pull Request #62892 · nodejs/node · GitHub
Skip to content

ffi: fix FLOAT_32 and FLOAT_64 type constants#62892

Open
watilde wants to merge 1 commit intonodejs:mainfrom
watilde:ffi-fixes
Open

ffi: fix FLOAT_32 and FLOAT_64 type constants#62892
watilde wants to merge 1 commit intonodejs:mainfrom
watilde:ffi-fixes

Conversation

@watilde
Copy link
Copy Markdown
Member

@watilde watilde commented Apr 22, 2026

Test code

$ cat test.js
const ffi = require('node:ffi');

const { functions } = ffi.dlopen('libm.so.6', {
  sinf: { parameters: [ffi.types.FLOAT_32], result: ffi.types.FLOAT_32 },
});

console.log(functions.sinf(1.0));

Before

$ ./node --experimental-ffi test.js
node:ffi:75
    throw error;
    ^

TypeError: Unsupported FFI type: float32
    at Object.dlopen (node:ffi:71:91)
    at Object.<anonymous> (/home/moku/Developments/watilde/node/test.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1829:14)
    at Object..js (node:internal/modules/cjs/loader:1969:10)
    at Module.load (node:internal/modules/cjs/loader:1552:32)
    at Module._load (node:internal/modules/cjs/loader:1354:12)
    at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
    at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
    at node:internal/main/run_main_module:33:47 {
  code: 'ERR_INVALID_ARG_VALUE'
}

Node.js v26.0.0-pre

After

$ ./node --experimental-ffi test.js
0.8414709568023682
(node:721215) ExperimentalWarning: FFI is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

@nodejs-github-bot nodejs-github-bot added ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run. labels Apr 22, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

@watilde
Copy link
Copy Markdown
Member Author

watilde commented Apr 23, 2026

@watilde watilde requested a review from cjihrig April 23, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants