Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. General Discussion
  3. About arduino sketch main function

About arduino sketch main function

Scheduled Pinned Locked Moved General Discussion
6 Posts 3 Posters 2.3k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Magic WM Offline
    Magic WM Offline
    Magic W
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
    • hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #2

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

      This allows us to do all the MySensors processing automatically.

      1 Reply Last reply
      0
      • Magic WM Offline
        Magic WM Offline
        Magic W
        wrote on last edited by
        #3

        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!

        1 Reply Last reply
        0
        • hekH Offline
          hekH Offline
          hek
          Admin
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • Magic WM Offline
            Magic WM Offline
            Magic W
            wrote on last edited by
            #5

            @hek said:

            attribute (weak)

            I search the MySensor project,the loop()/lsetup() is weak functions (attribute (weak)) ,but the main is not clear.
            0_1472979171726_微信截图_20160904164922.png

            mfalkviddM 1 Reply Last reply
            0
            • Magic WM Magic W

              @hek said:

              attribute (weak)

              I search the MySensor project,the loop()/lsetup() is weak functions (attribute (weak)) ,but the main is not clear.
              0_1472979171726_微信截图_20160904164922.png

              mfalkviddM Offline
              mfalkviddM Offline
              mfalkvidd
              Mod
              wrote on last edited by mfalkvidd
              #6

              @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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              17

              Online

              11.7k

              Users

              11.2k

              Topics

              113.1k

              Posts


              Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • MySensors
              • OpenHardware.io
              • Categories
              • Recent
              • Tags
              • Popular