Move to c++ #10535
Replies: 3 comments 2 replies
-
As also said there we stay on ino for now. Using vsc makes finding variables a breeze and many have been moved to TasmotaGlobal anyway. No energy wasted on moving to c++ for now. |
Beta Was this translation helpful? Give feedback.
-
TDer (ESPEasy) started to do. He run in problems with PlatformIO, to solve he had to do some ugly workarounds in code and PlatformIO scripts. |
Beta Was this translation helpful? Give feedback.
-
Maybe I can shed some light on why I spend so many hours in converting .ino into .cpp/.h files and this process uncovered lots and lots of new issues. I don't know the Tasmota code very well, so maybe the Tasmota code has less to gain here. I don't think I need to explain what the Arduino way is of compiling .ino files, but just to be sure some really essential parts are not lost, I will summarize it a bit.
This works all nice for smaller projects, but as soon as you try to use C++ objects as function parameters or return values you can easily run into very strange bugs that sadly not always manifest themselves during compile time. Another problem which may occur when compiling .ino files is that the pre-processor may act strange as it is next to impossible to know in what order files are being compiled. Thus if you're compiling .cpp files which do need those build specific defines, you MUST make sure the .h file setting those defines is also included in that .cpp file, or indirectly via another .h file that includes the needed one. Another thing to keep in mind.
myglobalvariables.cpp: #include "myglobalvariables.h"
bool myglobalbool = false; And there are lots of other things you can do wrong... ehh learn from :) Now the issues I encountered while doing all of this. Compiling in PlatformIO on Windows will sooner or later refuse to link with a very cryptic error message. Another problem with PlatformIO is that the documentation suggests to use There are lots and lots of other issues I had to overcome. So now the big question... was it worth it? I'm not sure if Tasmota will have the same benefit from it. Just a word of caution. |
Beta Was this translation helpful? Give feedback.
-
I saw this:
https://github.com/arendst/Tasmota/projects/3
But did not see anything else there. When I first started trying to do some development within Tasmota, I found it very difficult. The Arduino way is fine for small projects. It was created to make it more approachable for people that don't have a CS background. Making things simple is great, except when one tries to make them more simple than possible. Tasmota is big and complex. Arduino dumps all the INOs together to make one file, so some of the benefits of isolation of concerns is lost. It also makes it much easier to use variables far from where they are defined (and harder to find where they are really defined). Having said that, it would be a big job to change all the Tasmota core code to c++ and would probably need to be done all at once.
Is this a real project and is there a plan for it?
Beta Was this translation helpful? Give feedback.
All reactions