Arduino IDE Linking files

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

main

#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

#include "sample.h"

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

sample.h

#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

Rename sample.c to sample.cpp.

Wow it works!

Thank you a lot

You are welcome.