Skip to content

Overridable setup, loop and main #1138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cipriancraciun opened this issue Nov 27, 2012 · 2 comments
Closed

Overridable setup, loop and main #1138

cipriancraciun opened this issue Nov 27, 2012 · 2 comments
Labels
Component: Core Related to the code for the standard Arduino API

Comments

@cipriancraciun
Copy link

Following the same pattern as in the case of serialEvent, I'm proposing the following:

  • provide an empty implementation of the setup and loop functions;
  • mark all three functions (setup, loop and main) as __attribute__ (weak) so that the user is able to override them with customized versions;

P.S.: Granted that if the user overrides main he must manually call init.

P.P.S.: I'll provide in a minute the needed patch.

@ffissore
Copy link
Contributor

Thank for your patch. However, after having discussed it, we preferred to simplify the life of the developer making the IDE start with the BareMinimum sketch, thus solving the need to code them, even if empty.
Does this address your issue?

@cipriancraciun
Copy link
Author

Unfortunately my use case is a little bit different and the proposal of an "empty" template sketch doesn't actually help me.

I use the Arduino in an automation project, and I use it without the IDE. (I.e. I use a customized build system which relies only on GCC, avr-libc, and various generic build tools -- this is open-sourced at https://github.com/cipriancraciun/arduino-workbench )

Also in my case I use the Arduino C/C++ "standarrd library" only for the initialization, serial and pin operations, because I've written my own main function which replicates part of Arduino's main. But linking with Arduino's library I get duplicate symbols for main and missing symbols for setup and loop. (I also have open-sourced some of those libraries at https://github.com/cipriancraciun/arduino-libraries )

All in all if you don't apply this it doesn't bother me much as I use a custom installation.

@cmaglie cmaglie closed this as completed May 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core Related to the code for the standard Arduino API
Projects
None yet
Development

No branches or pull requests

3 participants