-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Fix compilation warnings #6446
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
Fix compilation warnings #6446
Conversation
Hi @jtentor , thanks for the contribution! Did you check if the addition increases the generated binary size? Second question: how did these warnings appear? Did you enable |
1st question:Yes, the addition increase the generated binary size.
With arduino original HardwareSerial.h, Print.h and Stream.h we have: With the addition to fix four warnings, three for virtual destructor and one for attribute not initialized we have: With the addition to fix only three virtual destructor warnings we have: It means we need 8 bytes for attribute initialization and 644 for virtual destructor. In this trivial code represents relatively a lot of code, but it becomes less important as code grows. 2nd question:I am editing and compiling with Eclipse IDE for C/C++ Developers Version: Neon.3 Release (4.6.3) Build id: 20170314-1500 with Jan Baeyens plugin (http://eclipse.baeyens.it/). Is possible Eclise have the "pedantic" option as default, but it is not set in my compilation options. In Arduino IDE we have -MMD option wich is not set in Eclipse IDE. The Eclipse IDE have a "Problems" windows where I found the four warnings, three for virtual destructor and one for attribute not initialized. Possible this warnings are not relevant for hobbyist products, but I am a software engineering and checking for no warnings in my compilations is a quality factor. Thanks @facchinm |
You are welcome 🙂 |
You are correct, embedded systems do not need unnecessary code bytes. I'm going to work on some -D options that enable or disable these virtual constructors As soon as I have them I will share them. Thank you. |
The only required virtual destructor is the one on the This doesn't only "make the static analyzer happy", it also fixes memory leaks (that's what the warning is for) on bigger projects which extend and add functionality of any of the Any way, we have discussed that before. For example, at #4466 |
Hi @Ivan-Perez , from your question Is not it important that the library behaves correctly? For software engineering is very important, but in small embedded systems or that who not use virtual destructor this adds unnecessary code. Remember in first instance, Arduino is for little embedded systems; it is a stakeholder decision. |
Can you give some specific examples where this has been a problem? By examples, I mean real projects and libraries. So far, every usage I've ever seen has been a statically allocated instance. Are people really using these classes with new & delete? |
Hi @jtentor and @PaulStoffregen, I showed an example on one comment in the PR I linked in my previous message. Here you have the link to that comment: #4466 (comment). I think it is a very simple example. Another person show me a workaround to fix my issue, so no complains, but it would be easier to just delete the object without using such workarounds. In my project, adding the |
Hi @jtentor , |
Remove compilation warnings