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. Development
  3. What are these bad practices ?

What are these bad practices ?

Scheduled Pinned Locked Moved Development
11 Posts 6 Posters 2.5k Views 4 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.
  • lrtsenarL Offline
    lrtsenarL Offline
    lrtsenar
    wrote on last edited by
    #1

    Hello,

    I tried to compile the MySensors v2.11 library with a code which was compiling and running perfectly with Mysensors v1.42 and Arduino 1.6.5 IDE.
    I saw in this new library a lot of bad practices like including "cpp" files by the following ways (#include should only include header files) :

    #include "core/MyHwESP8266.cpp"
    

    or including directly relatives path in #include (pathes should be managed by make file) :

    #include "drivers/AVR/DigitalWriteFast/digitalWriteFast.h"
    

    I saw this too (wh'y don't declare directly the relevant type like: "const uint8_t NODE_SENSOR_ID=255" because 'C' casts are from the previous century, no ?)

    #define NODE_SENSOR_ID			((uint8_t)255)
    

    I would like to point out that I am a professional C ++ developer since about 20 years.
    I post this because i've got a LOT of errors trying compiling my code in the new library. I'd already wrote a post to expose my problem but nobody is able to understand what happens and I already spent a lot of hours trying to solve the problem.

    As soon as I add a #include of custom header file, the compiler told me "multiple definition of" :

    [https://forum.mysensors.org/topic/5928/compilation-problem-under-arduino-1-8-1](link url)

    Maybe I'm wrong and sorry for the bad review but I'm so frustrated :-(
    If anyone could help...

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

      This bad practice (yes we are very well aware of it) is the only way we can allow users to control configuration and feature inclusion directly from the sketch.

      Earlier we had all configuration in a separate file distributed with the library. But it was much harder to handle for newbies (which is a target group for this library). You had to edit this file between sketch compilations to get different features (like SOFT-SPI) enabled.

      But the root cause is the Arduino IDEs crappy build system and this setup is (unfortunately) not uncommon.

      May I ask why you want to include core files yourself?

      1 Reply Last reply
      0
      • lrtsenarL Offline
        lrtsenarL Offline
        lrtsenar
        wrote on last edited by
        #3

        Hello,

        My previous post is only a review of the MySensors library, not what I do in my code.
        Anyway, thanks for the answer.
        I will continue searching for my compilation problem.
        May I ask you with which environment you compile your sketches (Linux, Arduino IDE, ... ) ?

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

          For linux we have setup automake... See here:
          https://www.mysensors.org/build/raspberry

          Our CI server runs Arduino IDE (headless) when verifying PRs and sketches.

          Personally I still load up the IDE when compiling. People here also use other builders like platformio

          1 Reply Last reply
          1
          • gohanG Offline
            gohanG Offline
            gohan
            Mod
            wrote on last edited by
            #5

            Does using visual studio with visual micro plug in make any difference than arduino ide when compiling code?

            1 Reply Last reply
            0
            • scalzS Offline
              scalzS Offline
              scalz
              Hardware Contributor
              wrote on last edited by scalz
              #6

              No. it uses arduino. Better it's a lot more ergonomic/friendly to use ;)

              FotoFieberF 1 Reply Last reply
              0
              • gohanG Offline
                gohanG Offline
                gohan
                Mod
                wrote on last edited by
                #7

                In fact I do use it, but I also use arduino ide for quick changes in code :smile:

                1 Reply Last reply
                0
                • lrtsenarL lrtsenar

                  Hello,

                  I tried to compile the MySensors v2.11 library with a code which was compiling and running perfectly with Mysensors v1.42 and Arduino 1.6.5 IDE.
                  I saw in this new library a lot of bad practices like including "cpp" files by the following ways (#include should only include header files) :

                  #include "core/MyHwESP8266.cpp"
                  

                  or including directly relatives path in #include (pathes should be managed by make file) :

                  #include "drivers/AVR/DigitalWriteFast/digitalWriteFast.h"
                  

                  I saw this too (wh'y don't declare directly the relevant type like: "const uint8_t NODE_SENSOR_ID=255" because 'C' casts are from the previous century, no ?)

                  #define NODE_SENSOR_ID			((uint8_t)255)
                  

                  I would like to point out that I am a professional C ++ developer since about 20 years.
                  I post this because i've got a LOT of errors trying compiling my code in the new library. I'd already wrote a post to expose my problem but nobody is able to understand what happens and I already spent a lot of hours trying to solve the problem.

                  As soon as I add a #include of custom header file, the compiler told me "multiple definition of" :

                  [https://forum.mysensors.org/topic/5928/compilation-problem-under-arduino-1-8-1](link url)

                  Maybe I'm wrong and sorry for the bad review but I'm so frustrated :-(
                  If anyone could help...

                  K Offline
                  K Offline
                  kimot
                  wrote on last edited by
                  #8

                  @lrtsenar
                  "multiple definition of"
                  I got too when experimenting with some libraries.
                  For example I edit my version "mcp_can.cpp" and rename original version to "mcp_can_old.cpp"
                  ( and leave it in original library directory )
                  Then when compiling I got this "multiple definition of" error.
                  When I rename original to "mcp_can.xxx" compilation works ok.
                  "mcp_can_old.cpp" is not included in any place in the code.
                  It seems that Arduino IDE uses at first ( for preprocessor ? ) all .h and .cpp files in the library directory.

                  1 Reply Last reply
                  1
                  • scalzS scalz

                    No. it uses arduino. Better it's a lot more ergonomic/friendly to use ;)

                    FotoFieberF Offline
                    FotoFieberF Offline
                    FotoFieber
                    Hardware Contributor
                    wrote on last edited by
                    #9

                    @scalz
                    I am not sure, if visualmicro really does the same as the arduino ide when compiling code. Ihave here code, that doesn't compile with visualmicro but it does with the arduino IDE....

                    1 Reply Last reply
                    0
                    • lrtsenarL Offline
                      lrtsenarL Offline
                      lrtsenar
                      wrote on last edited by lrtsenar
                      #10

                      I have found my problem. Please have a look at the link in mine (1st) post ;-)

                      1 Reply Last reply
                      0
                      • scalzS Offline
                        scalzS Offline
                        scalz
                        Hardware Contributor
                        wrote on last edited by scalz
                        #11

                        @FotoFieber maybe. i've not got this case yet. if i remember visualmicro use arduino core and boards. and both use the gcc toolchain; then i've not checked how it's compiled sure.. visualmicro still works nice for me. but i also use arduino ide ;)

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


                        18

                        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