# Building bare arduino code with zero warning

Thread Starter

#### Vindhyachal Takniki

Joined Nov 3, 2014
487
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.o
C:\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 expressions
C:\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 expressions

Code:
Stream.cpp.o
C:\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.o
C:\Program Files\Arduino\hardware\arduino\cores\arduino\Tone.cpp:119: warning: only initialized variables can be placed into program memory area

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.

#### Attachments

• 13.7 KB Views: 20

#### MikeML

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

Thread Starter

#### Vindhyachal Takniki

Joined Nov 3, 2014
487
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.

#### ErnieM

Joined Apr 24, 2011
8,019
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.

#### sirch2

Joined Jan 21, 2013
1,026
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...