Oh...!! So Linker has answer of my doubt. So fro example, if I have function which multiplies and adds two variables then header will only check the types and prototype of the function. and then Linker will do the math on them, Am I somewhat right?
If you have a header file, test.h, containing
int add(int a, int b);
int multiply(int a, int b);
and a source file, test.cpp, containing
#include "test.h"
int add(int a, int b)
{
return a+b;
}
int multiply(int a, int b)
{
return a * b;
}
and a sketch, stuff.ino, containing
#include "test.h"
void setup()
{
int c = add(3, 4);
int d = multiply(c, 5);
}
void loop()
{
}
there will be two compile operations. In the first one, stuff.cpp (created by the IDE from stuff.ino) will be compiled, and the compiler will check that the functions are known, and that the arguments to the calls match what the header file says that they should be (or that the values can be promoted to the appropriate type). That will result in stuff.o being created.
The second compile, for test.cpp, will result in the compiler checking that the functions are known, and that the implementation exactly matches the definition. That will result in test.o being created.
Then the linker gets called, with stuff.o and test.o, and a bunch of other stuff. It will find the add() function in test.o, and copy it into the hex file, reserving memory, translating addresses, etc. It will find the multiply function in test.o, and copy it into the hex file, making the same adjustments.
It will find main(), init(), setup(), and loop() in stuff.o, and other stuff in other files, and will copy them into the hex file, reserving memory, translating addresses, etc.
If, when the linker gets done, all the needed functions were found, the uploader is invoked to put the hex file on the Arduino, and it works. Well, it doesn't really do anything, because you have no proof that it didn't assign "The moon is a harsh mistress" to c and 4.5678902335643354677 to d. But, if you added Serial.begin() and Serial.print() calls, those functions would be added to the hex file, and you could have the proof you need.