rpicopter / MotionSensorExample

MPU6050/MPU6500/MPU9150/MPU9250 over I2c for RaspberryPi
137 stars 80 forks source link

inv_mpu_lib/inv_mpu.c:392:2: error: expected primary-expression before ‘.’ token #2

Open miky2k opened 9 years ago

miky2k commented 9 years ago

I clone your example in my cubieboard (armhf board), and giving make i receive this message.

Other projects compile correct.

gregd72002 commented 9 years ago

Your compiler does not support struct initialisations. You can change you compiler or initialise the "struct gyro_reg_s reg" in the following way: https://github.com/rpicopter/ArduinoMotionSensorExample/blob/master/inv_mpu.cpp#L409

miky2k commented 9 years ago

gregd72002 wrote:

Your compiler does not support struct initialisations.

Strange, i use debian wheezy ad it's gcc, there is some flag to enable C99 ?

Miky

miky2k commented 9 years ago

Ok i change CXX=g++ to CXX=gcc and now error disappear

As stated here: In ISO C99 you can give the elements in any order, specifying the array indices or structure field names they apply to, and GNU C allows this as an extension in C89 mode as well. This extension is not implemented in GNU C++. https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Designated-Inits.htmll

now it compile but not link: /tmp/cc5asmQ8.o: In function main': /home/miky/MotionSensorExample/main.c:11: undefined reference toms_open' /home/miky/MotionSensorExample/main.c:13: undefined reference to ms_update' MotionSensor/libMotionSensor.a(sensor.o): In functionms_open()': /home/miky/MotionSensorExample/MotionSensor/sensor.c:55: undefined reference to mpu_init(int_param_s*)' /home/miky/MotionSensorExample/MotionSensor/sensor.c:60: undefined reference tompu_set_sensors(unsigned char)' /home/miky/MotionSensorExample/MotionSensor/sensor.c:65: undefined reference to `mpu_set_gyro_fsr(unsigned short)'

gregd72002 commented 9 years ago

Well, the Makefile was written to support g++ only. Since you changed the compiler to gcc, further changes are needed to the Makefile.

Since you now how objects compiled, you can try changing the compiler back to g++ and issue 'make'. It should now invoke only the linker as all the objects are already compiled.

However, the permanent solution should be to convert the self initialised struct in inv_mpu.c into a new function that initialises them as indicated earlier.

Hope this helps.