1

I've set up a cross compiler for my raspberry pi, the one I found here: Installing Raspberry Pi Cross-Compiler

Now this has been working fine, up to the point where I want to use an I2c library (i2c-dev.h).

When compiling the code below with the arm-linux-gnueabihf-g++ compiler, I get an error:

In file included from src/I2c.cpp:8:0:
src/../Include/I2c.h:29:18: error: field ‘message’ has incomplete type
   struct i2c_msg message;
                  ^

Meanwhile, when I compile the code on a raspi, it simply runs.

#ifndef I2C_H_
#define I2C_H_

#include <linux/i2c-dev.h> // Defines i2c_msg
#include ...

using namespace std;


typedef struct {
    struct i2c_msg message;

    void (*callback)(int);
    int messageID;

} t_msgQueue;

Any ideas on a possible cause, or a solution on how I can make the cross compiler work properly?

Kees
  • 11
  • 3

2 Answers2

0

My first suspect would be differing GCC versions between the RPi and your cross compiler; GCC has been known to change how it processes #include statements over time.

Barring a version difference, check to ensure that a host include file hasn't been picked up somwhere by accident.

madscientist159
  • 550
  • 4
  • 12
  • I've checked the compiler versions: - cross compiler is GNU 4.8.3 - native compiler is GNU 4.9.4 The release notes however, do not discuss any changes regarding handling of #includes or structs. Furthermore, the header files used are identical. Any other ideas? – Kees Aug 08 '17 at 19:20
0

Problem was solved by adding a

#include <linux/i2c.h>

before the i2c-dev headers. Still no idea why the two compilers gave different results...

Kees
  • 11
  • 3