About arduino sketch main function

  • What is the relationship about hardware\arduino\cores\arduino\main.cpp and the MyMainDefaut.cpp?

  • Admin

    We implement our own main()-method overriding the default arduino-one.

    This allows us to do all the MySensors processing automatically.

  • Yeah,But why you can override the main()-method? in a project,The main() should not be the only one? I didn't understand the principle of internal ^_^ Looking forward to your reply!

  • Admin

    You mean how this is possible?

    loop()/setup()/main are so called weak functions (__attribute__ (weak)) which makes them overridable. We take advantage of this to simplify things for the sketch developer.

  • @hek said:

    attribute (weak)

    I search the MySensor project,the loop()/lsetup() is weak functions (attribute (weak)) ,but the main is not clear.

  • Mod

    @Magic-W it is the Arduino project that has the attribute, making it possible for other projects (such as MySensors) or a sketch developer to override.

Log in to reply

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.