About libraries

Hello everyone, I am kind of new in this world so first of all sorry for my question if it is too obvious or dumb.

It is clear that for working with Arduino libraries you need 2 files (.h with the header and .cpp with the code) but I am working with a camera whose library has just one file (the .h). The library is already made for the camera staff, so it is definitely right. The point is that the library works good with the example they provide and I dont get why runs without this .cpp file.

Point out that inside the .h file, the code of the functions are directly written there. So the question is: Is it possible to write directly in the header file the code with no needing of the .cpp file?

And the other issue is that in the example given they use a function (getblocks()) that i cannot find in this header file, so maybe is an Arduino function. Anyone any idea?

Thanks in advance and sorry for my english!!

The #include pre-processor directiive simply copies the included file into your file

So for example a file abc.def with the contents

abcde;
fghij

included into a second file containing

#include "abc.def"

joe
bill
fred

will create a new file

abcde;
fghij

joe
bill
fred

After which the compiler and the language rules take over. You can use the pre-processor to do lots of text expansion tricks including the full text of the 12 days of Christmas.

Mark

The library is already made for the camera staff, so it is definitely right.

Your conclusion is definitely wrong. No one should be implementing a class in a header file. If that is what was done, it is definitely NOT right.