no int main(void) in cpp file

Am I missing something obvious here. The main function has disappeared from the *.cpp file generated from the *.pde file.

Edit: Arduino 0021 on Linux.

Am I missing something obvious here.

Yes, you're missing telling us exactly what you're doing and with what.

I verify the pde file from the Arduino ide, then look at the cpp file generated in the applet directory, and there is no main function

You're still missing the "exactly" bit.

Exactly. I turn on my computer and wait for it to boot :) I start the arduino ide I write a sketch I click the verify button in the top left corner of the ide I correct any errors I click the verify button again I navigate to the arduino-0021/applet directory I open the cpp file I find in that directory and look at it I notice it doesn't have a main() function

You have a setup() and loop() in your .pde file, yeah? It runs on your Arduino too? So, sorry if I don't understand your question. Why are you looking for a .cpp file? Surely the only .cpp files that matter are the ones you wrote yourself?

I think you only need to explain what the .cpp file is and why you're looking at it. ;)

I don't use the Arduino ide. I wondered how a cpp file is compiled with no main function.

Your "main()" is in "main.cpp". I'm sorry, I don't have Linux or 0021, and I don't really understand what you're asking here.

This is the cpp file generated from the BareMinimum sketch compiled with Arduino-0017 ide

#include "WProgram.h"
void setup();
void loop();
void setup() {

void loop() {

int main(void)

      for (;;)
      return 0;

And here with the Arduino-0021 ide

#include "WProgram.h"
void setup();
void loop();
void setup() {
  // put your setup code here, to run once:


void loop() {
  // put your main code here, to run repeatedly: 

What function calls init() setup() and loop() in the second example?

The 'main()' in main.cpp?

Here is a list of files generated for the BareMinimum sketch


the main() function has been been moved somewhere else.

Yes, it has been moved to main.cpp, as of about 0018, I think. Why look! There it is, in your list.

the main() function has been been moved somewhere else.

It wasn't put somewhere else. It was read from somewhere else. Since the main.cpp file is exactly the same for every sketch, there is no reason to recreate it every time. Instead, it is simply included, causing it to be compiled.

Thankyou PaulS. I see. main() is in an Include file when avr-g++ is called. It is only a few lines and I would prefer to see it included with the projectname cpp file.

main() is in an Include file


An include file that generates a .o?

I don't think so.

How does main.cpp get incorporated into the project?

By linking it, just like tone, Print, WMath, HardwareSerial etc.

Linking. ok. Wrong terms but I knew what I meant :) I could see it in the output of avr-gcc but not sure where it came from.

not sure where it came from

See reply #7