Skip to content

[generation] unavailable inline C function #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Sunbreak opened this issue Feb 9, 2021 · 1 comment
Open

[generation] unavailable inline C function #10

Sunbreak opened this issue Feb 9, 2021 · 1 comment

Comments

@Sunbreak
Copy link
Collaborator

Sunbreak commented Feb 9, 2021

For example:

/**
* \ingroup libusb_misc
* Convert a 16-bit value from host-endian to little-endian format. On
* little endian systems, this function does nothing. On big endian systems,
* the bytes are swapped.
* \param x the host-endian value to convert
* \returns the value in little-endian byte order
*/
static inline uint16_t libusb_cpu_to_le16(const uint16_t x)
{
union {
uint8_t b8[2];
uint16_t b16;
} _tmp;
_tmp.b8[1] = (uint8_t) (x >> 8);
_tmp.b8[0] = (uint8_t) (x & 0xff);
return _tmp.b16;
}

results

/// \ingroup libusb_misc
/// Convert a 16-bit value from host-endian to little-endian format. On
/// little endian systems, this function does nothing. On big endian systems,
/// the bytes are swapped.
/// \param x the host-endian value to convert
/// \returns the value in little-endian byte order
int libusb_cpu_to_le16(
int x,
) {
_libusb_cpu_to_le16 ??=
_dylib.lookupFunction<_c_libusb_cpu_to_le16, _dart_libusb_cpu_to_le16>(
'libusb_cpu_to_le16');
return _libusb_cpu_to_le16(
x,
);
}

which doen't exist in dynamic library


Calling it would throw ArgumentError

test('libusb_cpu_to_le16', () {
expect(() => libusb.libusb_cpu_to_le16(0), throwsArgumentError);
});

Marked those inline functions @Deprecated('inline') as a workaround

@Sunbreak Sunbreak changed the title [generation] contain unavailable inline C function [generation] unavailable inline C function Feb 9, 2021
@Sunbreak
Copy link
Collaborator Author

Solved since https://github.com/woodemi/libusb.dart/releases/tag/0.3.23-nullsafety.0

Remain opened until nullable version deprecated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant