Go Down

Topic: Arduino IDE Linking files (Read 45 times) previous topic - next topic

Hi All,
I have the following three files in a single Arduino sketch

main
Code: [Select]

#include "sample.h"

void setup() {
  // put your setup code here, to run once:
  function(25);
}

void loop() {
  // put your main code here, to run repeatedly:

}


sample.c
Code: [Select]
#include "sample.h"

int function(int x) {
  return x*x;
}


sample.h
Code: [Select]
#ifndef A_H
#define A_H
int function(int x);
#endif


When I compile I get this: 'warning: undefined reference to `function(int)'
I've already tried saving all, restarting the IDE and reopening the file, and it did not work

Thank you in advance

Coding Badly


Rename sample.c to sample.cpp.



Coding Badly


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy