Adding multiple file arduino ; error

  1. I am using arduino uno r3 & arduino v1.0.6.
  2. Attached is my code.
  3. I have tried to add another .c & .h file & to main arduino file.
    By error comes saying: undefined reference to function.

code 1.zip (1.26 KB)

Sorry I did not look at the Zip, I am on a tablet.

However, for tabbed .H and .CPP extensions, you must #include "myheaderfile.h"
Note the quotes instead of <myheaderfile.h>

For .INO, they are automatically added.

Here is a multitab working Arduino sketch if you just need a sample. For 1.5.8
SPI-I2C-SD

Ray

Update.... I looked at the Zip this morning. You must name the ".c" to ".cpp" and it should then magically appear in the tabs with the .h when the INO is opened

  1. I have opened your project. But it didn't build. It shows error as I have attached.

  2. Coming back to my code, it have include the header file.

#include "shuffle.h"

but error still comes. i.e undefined reference to function.

  1. Even in main code I have prototyped the function which I am calling.
    But still same error

  2. I think i am not able to link arduino .ino files & .c file in which function to be called is defines

error.txt (5.1 KB)

Since the .ino file is compiled as a C++ program, you have to either put swap() in a .cpp file, or explicitly declare it as a C function, usually done like:

#ifdef __cplusplus
extern "C" {
#endif

extern void swap(char *x , char *y);

#ifdef __cplusplus
} // extern "C"
#endif

@westfw , completely missed that :slight_smile:
Solved that problem.

note: String& String::operator=(const __FlashStringHelper*)
String & operator = (const __FlashStringHelper *str);
^
Error compiling

plz help me