Strictly speaking C requires that functions be forward declared for the compiler to compile and link them.
In the first example you have not only declared the function but also defined it in the same space.
This is perfectly fine and legal for proper C.
The second example has the function definition after the loop but no declaration before the setup() function.
In order to get the compiler to “see” the bb() function you must declare it before the setup function.
This is valid and will compile.
// any code here
Now the compiler knows that you have a function named bb() defined elsewhere in the file. its prototype ( i.e returning void and taking no parameters) being declared ahead of its actual usage will allow the compiler to compile.
Arduino framework by itself does this job for you behind the scenes. thats why it compiles fine in the Arduino IDE.
If your function has variables, do you need to list out each one?
Sorry for not making my question clearer. If i have a function which accepts variables, I’m assuming i need to include that in the declaration and it needs to be after i have declared the individual variables?
int i, x, tempVariable;
//Can i declare it here?
//Does it need to have the variable included?
void SomeFunction(int i, int x);
void SomeFunction(int i, int x)
tempVariable = i + x;
Variables which are only declared and used inside a function do not need to be forward-declared outside the function – only if you want to share a global variables or use call a function, it needs to be known nbefore-hand.