Error with internal Arduino files while uploading sketch

Arduino gave me an error with the contents:
"Arduino: 1.8.14 Hourly Build 2021/01/29 11:34 (Mac OS X), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
/var/folders/bn/zd0qgf7d1h36sbyqwsymn4mc0000gp/T//cclTPmB8.ltrans0.ltrans.o: In function main': /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/main.cpp:43: undefined reference to setup'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Mega/Mega 2560."

I found the relevant code in the files, and it's highlighted in the screenshots.

Here's the code I was trying to upload:
(The error was only with this sketch.)
"int value = 0;

void loop() {
if (value == 255) {
while (value != 0) {
analogWrite(13, value);
value = value - 1;
}
}
else {
analogWrite(13, value);
value = value + 1;"

It is mandatory for an Arduino sketch to have a setup() function in it

Your sketch has no setup() function defined in it, hence the error

I omitted it because I did not need any setup.
Thanks for the answer!
(Weird error though. Maybe they'll remove that in version 2.0.1.
Currently running 1.8.14)

What's weird about it ?

@anon16461537, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with your project. And project in this case includes programming mistakes :wink: See About the Installation & Troubleshooting category

In future, please post code properly using code tags. The simplest way

  1. In the IDE, use tools -> autoformat
  2. In the IDE, use edit -> copy for forum; this will copy to the clipboard.
  3. Paste the clipboard in a post

Just like @UKHeliBob, I'm curious what is weird about it and why you would think that it will be removed?

If you don't need setup(), you can override the main() function in your sketch; in it's absolute simplest form

void loop();

int main void()
{
  for(;;)
  {
    loop();
  }
}

void loop()
{
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.