Building bare arduino code with zero warning - Page 1
Forum section: electronics / beginners

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: December 17, 2014, 03:39:04 pm
content: I like to build my code with zero warning/error. Warning in some cases may be unavoidable but can be most of cases.1. I have written a bare minimum code as below.Code:void setup(void){}void loop(void){}2. On building code I have seen warnings in three files as below:Code:HardwareSerial.cpp.oC:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp: In function 'void store_char(unsigned char, ring_buffer*)':C:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp:98: warning: comparison between signed and unsigned integer expressionsC:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp: In function 'void __vector_18()':C:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp:127: warning: unused variable 'c'C:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp: In member function 'void HardwareSerial::begin(long unsigned int, byte)':C:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp:368: warning: unused variable 'current_config'C:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp: In member function 'virtual size_t HardwareSerial::write(uint8_t)':C:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp:467: warning: comparison between signed and unsigned integer expressionsCode:Stream.cpp.oC:\Program Files\Arduino\hardware\arduino\cores\arduino\Stream.cpp: In member function 'bool Stream::find(char*)':C:\Program Files\Arduino\hardware\arduino\cores\arduino\Stream.cpp:78: warning: deprecated conversion from string constant to 'char*'Code:Tone.cpp.oC:\Program Files\Arduino\hardware\arduino\cores\arduino\Tone.cpp:119: warning: only initialized variables can be placed into program memory area3. Warnings in HardwareSerial.cpp , I have removed & file I have attached.On top of attached file I have also mentioned how I have removed those.Any comment/suggestion on that whether I have done right or wrong?4. Warning in other files I don't understand. Anyone else can help on that??5. I am not very legalese person, so don't if editing these files violates anything?6. I have also attached 3 original files in which there were errors.

author: bobcat
author_rank: Regular Contributor
timestamp: December 17, 2014, 11:55:19 pm
content: Those errors are a quirk of the Arduino environment. It compiles all libraries even if you are not using them, so those warnings are harmless unless you actually use the libraries. It's just sloppy code. The unused libraries are not linked unless you use them.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: December 18, 2014, 12:02:52 am
content: Libraries, premade files, IP and whatnot -- who would've thought anyone would make public releases when they drop warnings like they're hot?Worst I've seen personally was an ARM Cortex soft core that synthesized with ~300 warnings and such. Essentially unsupported, too. But I imagine others have far jucier stories to share, if we continue this tangent.Tim