I tried many solutions, but can’t get my program work.
main.h
short NWMP_acc[3];
short NWMP_gyro[3];
main.cpp
printf_( "%i,%i,%i, g\n", NWMP_gyro[YAW],NWMP_gyro[PITCH],NWMP_gyro[ROLL]);
other.cpp
#include "main.h"
NWMP_gyro[YAW] = (((buf[3]>>2)<<8) + buffer[0]);//multiple definition of `NWMP_gyro'
If I change to “extern short NWMP_acc[3];” than I get an error “undefined reference to `NWMP_acc'”
You need both with and without the
externIn your header you need:
But in one of your “.cpp” files you still need:
The reason for this is that the
externkeyword can be roughly thought of as meaning “I promise that somewhere in one file there exists an actual real thing that looks like this”.