can't compile with "#include"

hello,
i'm trying to use a function from another file. And apparently i'm not using "#include" correctly.
if i remove aprintf function code compiles fine.

The "aprintf" files are in the same as the "main" file directory

main file:

#include "aprintf.h"

//Push_Led.ino

//
// Turn LED only when the previous state of the  push btn was "ON"
//


int PinLed = 2;
int PinBtn = 10;
int ON = 1 ;
int OFF = 0;
int state ;
char BLAH;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(PinLed, OUTPUT);
  pinMode(PinBtn, INPUT_PULLUP);
  state = digitalRead(PinBtn);
}

void TurnLed( int flag){
	if(flag){
		digitalWrite(PinLed, HIGH);
		} else {
			digitalWrite(PinLed, LOW);
		}
	}


	void loop() {
    BLAH = 'A';
 ardprintf("Lets see - %s",BLAH);
}

aprintf.c:

int ardprintf(char s) {
};

and aprintf.h is :

#ifndef ARDPRINTF
#define ARDPRINTF
#define ARDBUFFER 16 //Buffer for storing intermediate strings. Performance may vary depending on size.

int ardprintf(char s) 


#undef ARDBUFFER
#endif
int ardprintf(char s)

huh?

AZZ:
and aprintf.h is :

//aprintf.h

#ifndef ARDPRINTF
#define ARDPRINTF
#define ARDBUFFER 16 //Buffer for storing intermediate strings. Performance may vary depending on size.

int ardprintf(char s) ; //<--- spot the semicolon

//...etc

ekhhh. >:( >:(

After adding the ";" life has a potential :slight_smile:

Now, getting:

[Stino - Start building "LED_turnonoff"...]
[  3%] Creating /tmp/Stino_build/LED_turnonoff/LED_turnonoff.ino.cpp.o...
/home/az/Dropbox/work/Arduino/Sketches/Examples/LED_turnonoff/LED_turnonoff.ino: In function 'void loop()':
/home/az/Dropbox/work/Arduino/Sketches/Examples/LED_turnonoff/LED_turnonoff.ino:40:32: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
  ardprintf("Lets see - %s",BLAH);
                                ^
/home/az/Dropbox/work/Arduino/Sketches/Examples/LED_turnonoff/LED_turnonoff.ino:40:32: error: too many arguments to function 'int ardprintf(char)'
In file included from /home/azyman/Dropbox/work/Arduino/Sketches/Examples/LED_turnonoff/LED_turnonoff.ino:1:0:
/home/az/Dropbox/work/Arduino/Sketches/Examples/LED_turnonoff/aprintf.h:23:5: note: declared here
 int ardprintf(char s) ;
     ^

[Stino - Exit with error code 1.]

And after changing the call to :

ardprintf('Y');

getting only:

/tmp/Stino_build/LED_turnonoff/LED_turnonoff.ino.cpp.o: In function `loop':
/home/az/Dropbox/work/Arduino/Sketches/Examples/LED_turnonoff/LED_turnonoff.ino:41: undefined reference to `ardprintf(char)'
collect2: error: ld returned 1 exit status

I moved h and c files over to library directory, since this is what stino "wants" after i click on "import library"....
it seemed to ignore these files if i put them into the same directory where the main file is...

not sure how to troubleshoot this further.

yes.
i simplified the code :

//test.ino
#include "aprintf.h"

int led = 13;

void setup() {
  // put your setup code here, to run once:
  pinMode(led, OUTPUT);
}

void loop() {
    led = ardprintf('Q');

}

in the ../test/libraries/aprintf/

aprint.h:

int ardprintf(char s) ;

aprint.c:

#include "aprintf.h"

int ardprintf(char s) {
 return 10 ;
};

And the output after "full build"

[Stino - Start building "test"...]
[  3%] Creating /tmp/Stino_build/test/test.ino.cpp.o...
[  6%] Creating /tmp/Stino_build/test/lib_aprintf/aprintf.c.o...
[  9%] Creating /tmp/Stino_build/test/core_arduino/hooks.c.o...
[ 12%] Creating /tmp/Stino_build/test/core_arduino/WInterrupts.c.o...
[ 16%] Creating /tmp/Stino_build/test/core_arduino/wiring.c.o...
[ 19%] Creating /tmp/Stino_build/test/core_arduino/wiring_analog.c.o...
[ 22%] Creating /tmp/Stino_build/test/core_arduino/wiring_digital.c.o...
[ 25%] Creating /tmp/Stino_build/test/core_arduino/wiring_pulse.c.o...
[ 29%] Creating /tmp/Stino_build/test/core_arduino/wiring_shift.c.o...
[ 32%] Creating /tmp/Stino_build/test/core_arduino/abi.cpp.o...
[ 35%] Creating /tmp/Stino_build/test/core_arduino/CDC.cpp.o...
[ 38%] Creating /tmp/Stino_build/test/core_arduino/HardwareSerial.cpp.o...
[ 41%] Creating /tmp/Stino_build/test/core_arduino/HardwareSerial0.cpp.o...
[ 45%] Creating /tmp/Stino_build/test/core_arduino/HardwareSerial1.cpp.o...
[ 48%] Creating /tmp/Stino_build/test/core_arduino/HardwareSerial2.cpp.o...
[ 51%] Creating /tmp/Stino_build/test/core_arduino/HardwareSerial3.cpp.o...
[ 54%] Creating /tmp/Stino_build/test/core_arduino/HID.cpp.o...
[ 58%] Creating /tmp/Stino_build/test/core_arduino/IPAddress.cpp.o...
[ 61%] Creating /tmp/Stino_build/test/core_arduino/main.cpp.o...
[ 64%] Creating /tmp/Stino_build/test/core_arduino/new.cpp.o...
[ 67%] Creating /tmp/Stino_build/test/core_arduino/Print.cpp.o...
[ 70%] Creating /tmp/Stino_build/test/core_arduino/Stream.cpp.o...
[ 74%] Creating /tmp/Stino_build/test/core_arduino/Tone.cpp.o...
[ 77%] Creating /tmp/Stino_build/test/core_arduino/USBCore.cpp.o...
[ 80%] Creating /tmp/Stino_build/test/core_arduino/WMath.cpp.o...
[ 83%] Creating /tmp/Stino_build/test/core_arduino/WString.cpp.o...
[ 87%] Creating /tmp/Stino_build/test/core_arduino/wiring_pulse.S.o...
[ 90%] Creating /tmp/Stino_build/test/core.a...
[ 93%] Creating /tmp/Stino_build/test/test.elf...
/tmp/Stino_build/test/test.ino.cpp.o: In function `loop':
/home/az/Dropbox/work/Arduino/Sketches/Examples/test/test.ino:12: undefined reference to `ardprintf(char)'
collect2: error: ld returned 1 exit status

[Stino - Exit with error code 1.]

If i try to compile in the 1.6.5 IDE (after i "add file .." and enable "detailed information") i get

Arduino: 1.6.5 (Linux), Board: "Arduino/Genuino Uno"

Build options changed, rebuilding all

/home/az/APPS/arduino-1.6.5-r5/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/home/az/APPS/arduino-1.6.5-r5/hardware/arduino/avr/cores/arduino -I/home/az/APPS/arduino-1.6.5-r5/hardware/arduino/avr/variants/standard /tmp/build724196081378720135.tmp/aprintf.c -o /tmp/build724196081378720135.tmp/aprintf.c.o 
/home/az/APPS/arduino-1.6.5-r5/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/home/az/APPS/arduino-1.6.5-r5/hardware/arduino/avr/cores/arduino -I/home/az/APPS/arduino-1.6.5-r5/hardware/arduino/avr/variants/standard /tmp/build724196081378720135.tmp/test.cpp -o /tmp/build724196081378720135.tmp/test.cpp.o 

<cut tons of output from std libraries >
/home/az/APPS/arduino-1.6.5-r5/hardware/tools/avr/bin/avr-ar rcs /tmp/build724196081378720135.tmp/core.a /tmp/build724196081378720135.tmp/Stream.cpp.o 
/home/az/APPS/arduino-1.6.5-r5/hardware/tools/avr/bin/avr-ar rcs /tmp/build724196081378720135.tmp/core.a /tmp/build724196081378720135.tmp/USBCore.cpp.o 
/home/az/APPS/arduino-1.6.5-r5/hardware/tools/avr/bin/avr-ar rcs /tmp/build724196081378720135.tmp/core.a /tmp/build724196081378720135.tmp/new.cpp.o 
/home/az/APPS/arduino-1.6.5-r5/hardware/tools/avr/bin/avr-gcc -w -Os -Wl,--gc-sections -mmcu=atmega328p -o /tmp/build724196081378720135.tmp/test.cpp.elf /tmp/build724196081378720135.tmp/aprintf.c.o /tmp/build724196081378720135.tmp/test.cpp.o /tmp/build724196081378720135.tmp/core.a -L/tmp/build724196081378720135.tmp -lm 
/tmp/build724196081378720135.tmp/test.cpp.o: In function `loop':
/home/az/APPS/arduino-1.6.5-r5/test.ino:12: undefined reference to `ardprintf(char)'
collect2: error: ld returned 1 exit status
Error compiling.

all right i've got this to work.
All files are in the same directory.
Should you choose to put it under library directory:
use the <>
create a subdirectory for you files
Add the library to list of libraries using your IDE.

//test.ino
#include "aaa.h"

int led = 13;

void setup() {
  // put your setup code here, to run once:
  pinMode(led, OUTPUT);
  Serial.begin(9600);
}

void loop() {
    // led = ardprintf('Q');
    for(int i=0; i< 10; i++){
        Serial.println("DA");
        delay(200);
    }

}

aaa.cpp <- attention on the extention

#include "aaa.h"

int aaa(int a){

	return a*a;
}

aaa.h

int aaa(int a);

The questions now i have :
a. Why am i instructed to include "Andruino.h", if it doesn't seem to be needed?
b. Why(where) do i need to use :
#ifdef __cplusplus
extern "C" {
#endif
// See Paul's post below
c. What is the correct way to use this functionality? ( the use of library)
d. What exactly is happening when i "add library" in the IDE ? Do i need to re-"add library" after i modified library files?

@Nick Gammon- save CPP file:
http://forum.arduino.cc/index.php?topic=175610.0

@PaulS, showed how to use .C file
http://forum.arduino.cc/index.php?topic=45003.0
unfortunately that didn't work for me.

I updated the thread below, since it addresses the same problem i had in much better details.
http://forum.arduino.cc/index.php?topic=175610.0