user3838: Arduino sketches usually feature a setup and loop function. Are these functions only provided for convenience or do they actually have special purposes? (e.g.: are some operations disallowed or allowed in setup and loop)
Are these two pieces of code equivalent:
Classic
void setup() {
    pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(1000);
    digitalWrite(LED_BUILTIN, LOW);
    delay(1000);
}

Without loop
void setup() {
    pinMode(LED_BUILTIN, OUTPUT);

    while(true) {
        digitalWrite(LED_BUILTIN, HIGH);
        delay(1000);
        digitalWrite(LED_BUILTIN, LOW);
        delay(1000);
    }
}


void loop() {
}

Is it possible to write code without either setup or loop, providing, for example, a main method or other entry point?

user10794: 
Arduino sketches usually feature a setup and loop function. Are these functions only provided for convenience or do they actually have special purposes? 

They throw in an extra function call to init which initializes the timers which let millis, micros and delay work without further effort. Other than that, no.
This code compiles (and runs) under the IDE:
int main ()
  {
  }

Effectively the IDE generates code like this:
int main ()
  {
  init ();  // set up timers
  setup (); // your own initialization
  while (true)
    loop ();  // stuff you want to keep doing
  }

They have fiddled with it since then, as Ignacio Vazquez-Abrams said, but basically you can ignore that. There is nothing particularly special about setup and loop.
You can use main like I showed above. You can do everything in setup if you want. You can do everything in loop if you want (if you never return from it).
Remember, you are dealing with a C++ compiler here. Functions don't have some magic significance based on their names.

user3508: 
Is it possible to write code without either setup or loop, providing, for example, a main method or other entry point?

The last time I used the IDE, you could have a project with no .ino/.pde file, only .cppfiles; since it's the mangling of the .ino into a .cpp that defines the main function, if you bypass that step then you can define your own main.
If the IDE no longer allows this (as I've heard) you can still do the same thing with e.g. a Makefile-based build outside the IDE, without giving up the Arduino libraries. The caveats that I know of are:

You should #include "Arduino.h" if you want access to the library functions.
You should call init() if you want the library to set up peripherals the way you're used to.
You should put the serialEvent code that Gerben points out in your mainloop if you want a serialEvent handler to run (but you probably don't need this anyway if you want to write your own mainloop).


user368: 
Are these functions only provided for convenience or do they actually have special purposes?

The Arduino libraries do a tiny bit of housekeeping with loop(), related to serial handling.

Are these two pieces of code equivalent:

Only if you never use serial events.

Is it possible to write code without either setup or loop, providing, for example, a main method or other entry point?

Not while strictly using the Arduino libraries via the IDE; the linker will complain of either duplicate main definitions or of missing setup or loop definitions.

user2881: Those pieces of code are pretty much the same.
If you look at the Arduino source code you'll see:
setup();

for (;;) {
  loop();
  if (serialEventRun) serialEventRun();
}

(I'm not sure what serialEventRun() does.)
I don't think you can 'overload' the main function declaration. Also note that the main function calls init, which e.g. configures the timers, so millis() etc. will work.

3838: <p>Arduino sketches usually feature a <a href="http://arduino.cc/en/Reference/Setup"><code>setup</code></a> and <a href="http://arduino.cc/en/Reference/Loop"><code>loop</code></a> function. Are these functions only provided for convenience or do they actually have special purposes? (e.g.: are some operations disallowed or allowed in setup and loop)</p>

<p>Are these two pieces of code equivalent:</p>

<p><strong>Classic</strong></p>

<pre><code>void setup() {
    pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(1000);
    digitalWrite(LED_BUILTIN, LOW);
    delay(1000);
}
</code></pre>

<p><strong>Without loop</strong></p>

<pre><code>void setup() {
    pinMode(LED_BUILTIN, OUTPUT);

    while(true) {
        digitalWrite(LED_BUILTIN, HIGH);
        delay(1000);
        digitalWrite(LED_BUILTIN, LOW);
        delay(1000);
    }
}


void loop() {
}
</code></pre>

<p>Is it possible to write code without either setup or loop, providing, for example, a <code>main</code> method or other entry point?</p>
 10794: <blockquote>
  <p>Arduino sketches usually feature a setup and loop function. Are these functions only provided for convenience or do they actually have special purposes? </p>
</blockquote>

<p>They throw in an extra function call to <code>init</code> which initializes the timers which let <code>millis</code>, <code>micros</code> and <code>delay</code> work without further effort. Other than that, no.</p>

<p>This code compiles (and runs) under the IDE:</p>

<pre><code>int main ()
  {
  }
</code></pre>

<p>Effectively the IDE generates code like this:</p>

<pre><code>int main ()
  {
  init ();  // set up timers
  setup (); // your own initialization
  while (true)
    loop ();  // stuff you want to keep doing
  }
</code></pre>

<p>They have fiddled with it since then, as Ignacio Vazquez-Abrams said, but basically you can ignore that. There is nothing particularly special about <code>setup</code> and <code>loop</code>.</p>

<p>You can use <code>main</code> like I showed above. You can do everything in <code>setup</code> if you want. You can do everything in <code>loop</code> if you want (if you never return from it).</p>

<p>Remember, you are dealing with a C++ compiler here. Functions don't have some magic significance based on their names.</p>
 3508: <blockquote>
  <p>Is it possible to write code without either setup or loop, providing, for example, a main method or other entry point?</p>
</blockquote>

<p>The last time I used the IDE, you could have a project with no <code>.ino</code>/<code>.pde</code> file, only <code>.cpp</code>files; since it's the mangling of the <code>.ino</code> into a <code>.cpp</code> that defines the <code>main</code> function, if you bypass that step then you can define your own <code>main</code>.</p>

<p>If the IDE no longer allows this (as I've heard) you can still do the same thing with e.g. a Makefile-based build outside the IDE, without giving up the Arduino libraries. The caveats that I know of are:</p>

<ul>
<li>You should <code>#include "Arduino.h"</code> if you want access to the library functions.</li>
<li>You should call <code>init()</code> if you want the library to set up peripherals the way you're used to.</li>
<li>You should put the <code>serialEvent</code> code that Gerben points out in your mainloop if you want a <code>serialEvent</code> handler to run (but you probably don't need this anyway if you want to write your own mainloop).</li>
</ul>
 368: <blockquote>
  <p>Are these functions only provided for convenience or do they actually have special purposes?</p>
</blockquote>

<p>The Arduino libraries do a tiny bit of housekeeping with <code>loop()</code>, related to <a href="http://arduino.cc/en/Reference/SerialEvent">serial handling</a>.</p>

<blockquote>
  <p>Are these two pieces of code equivalent:</p>
</blockquote>

<p>Only if you never use serial events.</p>

<blockquote>
  <p>Is it possible to write code without either setup or loop, providing, for example, a main method or other entry point?</p>
</blockquote>

<p>Not while strictly using the Arduino libraries via the IDE; the linker will complain of either duplicate <code>main</code> definitions or of missing <code>setup</code> or <code>loop</code> definitions.</p>
 2881: <p>Those pieces of code are pretty much the same.</p>

<p>If you look at the <a href="https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/main.cpp#L43-L48" rel="nofollow noreferrer">Arduino source code</a> you'll see:</p>

<pre><code>setup();

for (;;) {
  loop();
  if (serialEventRun) serialEventRun();
}
</code></pre>

<p>(I'm not sure what <code>serialEventRun()</code> does.)</p>

<p>I don't think you can 'overload' the <code>main</code> function declaration. Also note that the main function calls <code>init</code>, which e.g. configures the timers, so <code>millis()</code> etc. will work.</p>
