Undefined reference to the setup and loop functions.

I don't understand why these errors arise

core.a(main.cpp.o): In function main': C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/main.cpp:5: undefined reference to setup'
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/main.cpp:15: undefined reference to `loop'

I deleted all the fluff. This is an attempt to learn the tone function.

#include "pitches.h"

int KLM = NOTE_A4;

void setup() {
tone(8, KLM, 1000);
noTone(4);
delay(50);
}

void loop() {
}

Did you really name your sketch main? That is a really bad idea. Now you know why.

PaulS:
Did you really name your sketch main? That is a really bad idea. Now you know why.

It might be a bad idea but doesn't prevent a compile....

main.JPG

@Hankering4u: Please edit your post, select the code, and put it between [code][/code] tags.

You can do that by hitting the “Code” icon above the posting area. It is the first icon, with the symbol: </>

Please use code tags.

Read this before posting a programming question

How to use this forum

What is the name of your sketch? Which version of the IDE are you using? Which Arduino board are you compiling for?

Hi,
It compiled for me
1.6.7, Win 7, UNO
Have you got pitches.h in the same folder as your sketch, it should appear in the tabs next to your sketch name tab.

corner.jpg
Tom…

JimboZA:
It might be a bad idea but doesn't prevent a compile....

... on IDE 1.6.6 and later. It does prevent on 1.6.5 and older.

The new builder puts core and sketch files in separate directories under the build directory; the old one lumps them together.