dart-lang / native

Dart packages related to FFI and native assets bundling.
BSD 3-Clause "New" or "Revised" License
157 stars 44 forks source link

How to address type-map for enums? #1723

Closed Ben1980 closed 3 hours ago

Ben1980 commented 3 hours ago

I get the follwoing warning.

[SEVERE] : The integer type used for enums is implementation-defined. FFIgen tries to mimic the integer sizes chosen by the most common compilers for the various OS and architecture combinations. To prevent any crashes, remove the enums from your API surface. To rely on the (unsafe!) mimicking, you can silence this warning by adding silence-enum-warning: true to the FFIgen config. Affected enums:
        dc_direction_t
        dc_event_type_t
        dc_family_t

Tried fixing it with

type-map:
  'native-types':
    'enum':
      'lib': 'pkg_ffi'
      'c-type': 'Int32' or 'enum'
      'dart-type': 'int'

But get the same Warning:

[SEVERE] : The integer type used for enums is implementation-defined. FFIgen tries to mimic the integer sizes chosen by the most common compilers for the various OS and architecture combinations. To prevent any crashes, remove the enums from your API surface. To rely on the (unsafe!) mimicking, you can silence this warning by adding silence-enum-warning: true to the FFIgen config. Affected enums:
        dc_direction_t
        dc_event_type_t
Ben1980 commented 3 hours ago

Found a solution

type-map:
  'typedefs':
    'dc_direction_t':
      'lib': 'pkg_ffi'
      'c-type': 'Int32'
      'dart-type': 'int'

This could be better documented how to do such things.