While compiling some Arduino C file I get an error "undefined reference to `readArms()'"
The code can be found on paste bin.
But basically what happens is:
In the INO file I use:
readArms();
Which is declared in "armfunctions.h" and "armfunctions.c"
The .h file contains
void readArms(void);
And the .c file :
void readArms(void){
float motor1 = 0.0;
int motor = 0;
motor = analogRead(READMOTOR1);
motor1 = (float)motor;
motor1 = (motor1 - 87.0) * (400.0/(1007.0-87.0));
delay(1000);
}
I have been researching this for hours today, making and testing various sketches, and have found (as you've already found) changing them to .cpp
is a workaround, but if you want to specifically create a c file, you must wrap the prototypes in the header to get it to compile. There are a few good posts about it, but the crux of the issue, in your .h
file put:
#ifdef __cplusplus
extern "C" {
#endif
void readArms(void);
#ifdef __cplusplus
}
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With