Skip to content
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

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

Open
miky2k opened this issue Jan 28, 2015 · 4 comments

Comments

@miky2k
Copy link

miky2k commented Jan 28, 2015

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

Other projects compile correct.

@gregd72002
Copy link
Contributor

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
Copy link
Author

miky2k commented Jan 29, 2015

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
Copy link
Author

miky2k commented Jan 29, 2015

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
Copy link
Contributor

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.

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

2 participants