native icon indicating copy to clipboard operation
native copied to clipboard

In ffigen, options for "type-map" ignored

Open jvxgit opened this issue 6 months ago • 0 comments

Hi,

I just updated ffigen to the latest version. Unfortunately, it seems that the declarations for "type-map" are somehow ignored.

Here is my example:

File "my_header.h":

void my_function(Char val);`

File "config.yaml" (taken from the official documentation for type-map):

output: 'out.dart'
headers:
  entry-points:
    - 'my_header.h'
type-map:
  'native-types': # Targets native types.
    'Char':
      'lib': 'pkg_ffi' # predefined import.
      'c-type': 'Char'
      'dart-type': 'int'      

Command to run ffigen:

dart  run ffigen  --config  config.yaml

Output when running:

Running in Directory: 'MYFOLDER'
[WARNING]: Prefer adding Key '[name]' to your config.
[WARNING]: Prefer adding Key '[description]' to your config.
Input Headers: [.\my_header.h]
[SEVERE] : Header .\my_header.h: Total errors/warnings: 1.
[SEVERE] :     .\my_header.h:1:18: error: unknown type name 'Char' [Semantic Issue]
Finished, Bindings generated in out.dart

I expected that "Char" would be replaced by "ffi.int" in the generated Dart code without reported error. Or do I misunderstand the purpose of "type-map" in ffigen?

Thank you and best regards

Hauke

jvxgit avatar May 14 '25 08:05 jvxgit