Serial debug from c file

Hello. I excuse in prior for this pretty noop question. I have tried to find the answer for my question on google and on this page but can apparently not type in the right "question". Here is my question: I have a project containing a .c file (due to the shield I use). I would like t o be able to print to the serial port from this C code however I can not use Serial.println() etc. from the C file. What should I include inorder to do so?

Thanks in advance:)

however I can not use Serial.println() etc. from the C file.

Why not?

What should I include inorder to do so?

Have you included WProgram.h in the c file?

Hi Paul. Thanks for the fast reply. I simply get Serial undeclared (first use of this function) when I compile. The print statement is used like this:

Serial.println("text");

Yes i have

#include "WProgram.h"

As the very first line in my program.

What's included in the sketch?

It actually seems like I have a fundamental problem in understanding the linking/include process. I have made a small example with three files:

  • Build_test.pde
  • cfile.c
  • cfile.h

Which are as follows:

Build_test.pde:

#include "cfile.h"

void setup(){
;
}

void loop(){
foo();
}

cfile.c:

#include "WProgram.h"
#include "cfile.h"
void foo(){
int i = 0;
}

cfile.h:

void foo(void);

However when i compile:
It returns undefiled reference to foo()
Can anyone tell me what I am doing wrong?

Rename cfile.c to cfile.cpp.