I have noticed the library lets me compile the C code using a C++ compiler (hence the #ifdef __cplusplus extern "C" { #endif blocks).
However I am getting errors when I compile the library, using g++ 7.5.0:
vendor/libi2c/src/i2c.c: In function ‘ssize_t i2c_ioctl_read(const I2CDevice*, unsigned int, void*, size_t)’:
vendor/libi2c/src/i2c.c:122:28: error: invalid conversion from ‘void*’ to ‘__u8* {aka unsigned char*}’ [-fpermissive]
ioctl_msg[1].buf = buf;
^~~
vendor/libi2c/src/i2c.c:135:28: error: invalid conversion from ‘void*’ to ‘__u8* {aka unsigned char*}’ [-fpermissive]
ioctl_msg[0].buf = buf;
^~~
vendor/libi2c/src/i2c.c: In function ‘ssize_t i2c_ioctl_write(const I2CDevice*, unsigned int, const void*, size_t)’:
vendor/libi2c/src/i2c.c:158:35: error: invalid conversion from ‘const void*’ to ‘const unsigned char*’ [-fpermissive]
const unsigned char *buffer = buf;
^~~
vendor/libi2c/src/i2c.c: In function ‘ssize_t i2c_write(const I2CDevice*, unsigned int, const void*, size_t)’:
vendor/libi2c/src/i2c.c:265:35: error: invalid conversion from ‘const void*’ to ‘const unsigned char*’ [-fpermissive]
const unsigned char *buffer = buf;
^~~
Makefile:28: recipe for target 'build/./vendor/libi2c/src/i2c.c.o' failed
The C++ compiler will not let you implicitly convert pointers.
This should be fixed by casting explicitly to (unsigned char*) (source).
Is there a compiler setting I am missing? -fpermissive is suggested but wouldn't that allow all implicit pointer conversions? All I changed is replacing $(CC) in the Makefile with $(CXX) for *.c, which should work, because of your extern C blocks.
I have noticed the library lets me compile the C code using a C++ compiler (hence the
#ifdef __cplusplus extern "C" { #endif
blocks).However I am getting errors when I compile the library, using g++ 7.5.0:
The C++ compiler will not let you implicitly convert pointers.
This should be fixed by casting explicitly to
(unsigned char*)
(source).Is there a compiler setting I am missing?
-fpermissive
is suggested but wouldn't that allow all implicit pointer conversions? All I changed is replacing$(CC)
in the Makefile with$(CXX)
for*.c
, which should work, because of yourextern C
blocks.Thank you in advance.
PS: Thanks for making this library