Microsemi / switchtec-user

Userspace code for the Microsemi PCIe switch
MIT License
46 stars 49 forks source link

redefinition of i2c objects in linux. #221

Open mwcarlis opened 4 years ago

mwcarlis commented 4 years ago

We run into the following issue when trying to compile in linux.
One workaround is to remove libi2c-dev, but it seems the issue is the way it includes i2c-dev.h and i2c.h.

switchtec-user# make
  CC    lib/platform/linux-i2c.c
In file included from lib/platform/linux-i2c.c:46:0:
/usr/include/linux/i2c-dev.h:37:8: error: redefinition of 'struct i2c_msg'
 struct i2c_msg {
        ^
In file included from lib/platform/linux-i2c.c:45:0:
/usr/include/linux/i2c.h:68:8: note: originally defined here
 struct i2c_msg {
        ^
In file included from lib/platform/linux-i2c.c:46:0:
/usr/include/linux/i2c-dev.h:90:7: error: redefinition of 'union i2c_smbus_data'
 union i2c_smbus_data {
       ^
In file included from lib/platform/linux-i2c.c:45:0:
/usr/include/linux/i2c.h:129:7: note: originally defined here
 union i2c_smbus_data {
       ^
lib/platform/linux-i2c.c: In function 'i2c_msg_pec':
lib/platform/linux-i2c.c:87:14: warning: pointer targets in passing argument 1 of 'crc8' differ in signedness [-Wpointer-sign]
  return crc8(msg->buf, byte_count, pec, false);
              ^
In file included from lib/platform/linux-i2c.c:28:0:
lib/platform/../crc.h:34:9: note: expected 'uint8_t * {aka unsigned char *}' but argument is of type 'char *'
 uint8_t crc8(uint8_t *msg_ptr, uint32_t byte_cnt, uint32_t oldchksum,
         ^
lib/platform/linux-i2c.c: In function 'i2c_gas_cap_get':
lib/platform/linux-i2c.c:224:14: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
  msgs[0].buf = &command_code;
              ^
lib/platform/linux-i2c.c:228:14: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
  msgs[1].buf = rx_buf;
              ^
lib/platform/linux-i2c.c: In function 'i2c_gas_data_write':
lib/platform/linux-i2c.c:303:10: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
  msg.buf = (uint8_t *)i2c_data;
          ^
lib/platform/linux-i2c.c: In function 'i2c_gas_write_status_get':
lib/platform/linux-i2c.c:340:14: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
  msgs[0].buf = &command_code;
              ^
lib/platform/linux-i2c.c:344:14: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
  msgs[1].buf = rx_buf;
              ^
lib/platform/linux-i2c.c: In function 'i2c_gas_data_read':
lib/platform/linux-i2c.c:470:14: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
  msgs[0].buf = (uint8_t *)read_command;
              ^
lib/platform/linux-i2c.c:475:14: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
  msgs[1].buf = (uint8_t *)read_response;
              ^
lib/platform/linux-i2c.c: At top level:
cc1: warning: unrecognized command line option '-Wno-initializer-overrides'
Makefile:114: recipe for target 'build/lib/platform/linux-i2c.o' failed
make: *** [build/lib/platform/linux-i2c.o] Error 1
lsgunth commented 4 years ago

That's odd, the headers in Debian do not have the duplicate define and both headers are clearly required. What distro and version are you using?

According to this similar issue you may also have to remove the libi2c-dev package as it replaces the i2c-dev header for some reason:

https://github.com/myriadrf/Novena-RF/issues/18