# Building bare arduino code with zero warning

Discussion in 'Embedded Systems and Microcontrollers' started by Vindhyachal Takniki, Dec 17, 2014.

1. ### Vindhyachal Takniki Thread Starter Member

Nov 3, 2014
349
6
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 (Text):
1.
2. void setup(void)
3. {
4. }
5.
6. void loop(void)
7. {
8. }
9.
2. On building code I have seen warnings in three files as below:
Code (Text):
1.
2. HardwareSerial.cpp.o
3. C:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp: In function 'void store_char(unsigned char, ring_buffer*)':
4. C:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp:98: warning: comparison between signed and unsigned integer expressions
5. C:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp: In function 'void __vector_18()':
6. C:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp:127: warning: unused variable 'c'
7. C:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp: In member function 'void HardwareSerial::begin(long unsigned int, byte)':
8. C:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp:368: warning: unused variable 'current_config'
9. C:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp: In member function 'virtual size_t HardwareSerial::write(uint8_t)':
10. C:\Program Files\Arduino\hardware\arduino\cores\arduino\HardwareSerial.cpp:467: warning: comparison between signed and unsigned integer expressions
11.
12.

Code (Text):
1.
2. Stream.cpp.o
3. C:\Program Files\Arduino\hardware\arduino\cores\arduino\Stream.cpp: In member function 'bool Stream::find(char*)':
4. C:\Program Files\Arduino\hardware\arduino\cores\arduino\Stream.cpp:78: warning: deprecated conversion from string constant to 'char*'
5.
6.

Code (Text):
1.
2. Tone.cpp.o
3. C:\Program Files\Arduino\hardware\arduino\cores\arduino\Tone.cpp:119: warning: only initialized variables can be placed into program memory area
4.
5.
6.

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

File size:
13.7 KB
Views:
20
2. ### MikeML AAC Fanatic!

Oct 2, 2009
5,450
1,066
If I compiled this code, I would not get these errors. Your install is screwed up. Go and do a fresh install.

3. ### Vindhyachal Takniki Thread Starter Member

Nov 3, 2014
349
6
These are not error, only warnings.
Code gets compiled without error.
I don't want any warning also. Since sometimes (most of times IMHO), warnings are serious error.

4. ### ErnieM AAC Fanatic!

Apr 24, 2011
7,394
1,607
A compiler warning typically means "the human probably made a mistake here, but I am going to take a good guess of what was intended."

Here you have two types of warnings: "comparison between signed and unsigned integer expressions", and "unused variable"

If you declare a variable then do not use it so be it, as long as you are aware of this. You have the warning that gives you options (delete or comment out that line).

The comparison is trickier. Sometimes that works, sometimes it doesn't. Depends on what else is happening. I would jump all over that to fix a problem before it becomes a hard to find bug.

5. ### sirch2 Well-Known Member

Jan 21, 2013
1,008
351
Arduino is open source, so you can fix the code creating those warning in the Arduino libraries and submit your fixes back to the community, or you can just get on with your life...

ErnieM likes this.