user15379: I use VSCode, not the Arduino IDE. I saw and tried to use a lot of code snippets which are provided for Arduino projects...
So when I copy/paste these examples into my VSCode and try to compile it fails. (I won't believe that people offer non-working examples.) 
When I place the functions above the function calls it compiles.
Is this normal behavior or do I have to add some settings to get this working as provided?
Fails in VSCode (works in Arduino IDE):
#include "Arduino.h"
void setup() {
}
int zero = 0;

void loop() {
  zero = myfunction();
}

int myfunction(){
  return 0;
}

Works in VSCode (Works in Arduino IDE):
#include "Arduino.h"

void setup() {
}
int zero = 0;

int myfunction(){
  return 0;
}

void loop() {
  zero = myfunction();
}


user47344: You need to declare your function before you use it.  So either the whole function body needs to be before the usage, or you must add a function prototype declaration.
void myfunction();

myfunction();

void myfunction(){
  return 0;
}


15379: <p>I use VSCode, not the Arduino IDE. I saw and tried to use a lot of code snippets which are provided for Arduino projects...</p>

<p>So when I copy/paste these examples into my VSCode and try to compile it fails. (I won't believe that people offer non-working examples.) </p>

<p>When I place the functions above the function calls it compiles.</p>

<p>Is this normal behavior or do I have to add some settings to get this working as provided?</p>

<p><strong>Fails in VSCode</strong> (works in Arduino IDE):</p>

<pre><code>#include "Arduino.h"
void setup() {
}
int zero = 0;

void loop() {
  zero = myfunction();
}

int myfunction(){
  return 0;
}
</code></pre>

<p><strong>Works in VSCode</strong> (Works in Arduino IDE):</p>

<pre><code>#include "Arduino.h"

void setup() {
}
int zero = 0;

int myfunction(){
  return 0;
}

void loop() {
  zero = myfunction();
}
</code></pre>
 47344: <p>You need to declare your function before you use it.  So either the whole function body needs to be before the usage, or you must add a <a href="http://www.cplusplus.com/articles/yAqpX9L8/" rel="noreferrer">function prototype</a> declaration.</p>

<pre><code>void myfunction();

myfunction();

void myfunction(){
  return 0;
}
</code></pre>
