anilgkts / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

warnings from arduino libraries, #963

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
verify just your basic sketch, BUT with warnings turned on.

( I have warnings turned on,as I'm trying to learn better C codding ).

I get the following  warnings,which to me look like library warnigns,
   can we get them fixed please ?

C:\Program 
Files\Arduino\arduino-1.0.1\hardware\arduino\cores\arduino\HardwareSerial.cpp: 
In function 'void store_char(unsigned char, ring_buffer*)':
C:\Program 
Files\Arduino\arduino-1.0.1\hardware\arduino\cores\arduino\HardwareSerial.cpp:82
: warning: comparison between signed and unsigned integer expressions
C:\Program 
Files\Arduino\arduino-1.0.1\hardware\arduino\cores\arduino\HardwareSerial.cpp: 
In member function 'virtual size_t HardwareSerial::write(uint8_t)':
C:\Program 
Files\Arduino\arduino-1.0.1\hardware\arduino\cores\arduino\HardwareSerial.cpp:39
0: warning: comparison between signed and unsigned integer expressions

also

C:\Program 
Files\Arduino\arduino-1.0.1\hardware\arduino\cores\arduino\Print.cpp: In member 
function 'size_t Print::print(const __FlashStringHelper*)':
C:\Program 
Files\Arduino\arduino-1.0.1\hardware\arduino\cores\arduino\Print.cpp:44: 
warning: '__progmem__' attribute ignored

and

C:\Program 
Files\Arduino\arduino-1.0.1\hardware\arduino\cores\arduino\Tone.cpp:93: 
warning: only initialized variables can be placed into program memory area

Original issue reported on code.google.com by drjohnsm...@gmail.com on 24 Jun 2012 at 10:48

GoogleCodeExporter commented 9 years ago
Attached are patch files for the latest release of Arduino 1.0.1, to remove 
some of the many compiler warnings.  These warnings are (mostly) harmless, but 
their quantity
obscures warnings in the user's own code.  The libraries were compiled using 
avr-gcc 4.5.3 and with the FLAGS

CPPFLAGS      = -Os -Wall -Wextra -Wconversion -Wcast-align -Wshadow \
                -ffunction-sections -fdata-sections -fno-exceptions \
                -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION)
CFLAGS        = -std=c99 -pedantic -Wpointer-arith -Wstrict-prototypes 
-Wmissing-prototypes
CXXFLAGS      = -fno-exceptions -Wsign-promo

The fixes are mostly casts, to deal with C's automatic integer promotions.  In 
a couple of cases data structures have been changed to avoid pointer alignment 
error messages, and some shadowed variables have been renamed.

C W Rose

Original comment by cwrseckf...@gmail.com on 5 Jul 2012 at 5:37

Attachments:

GoogleCodeExporter commented 9 years ago
thanks

dont know what to do with a diff file though,
   whens the next release ? 

Original comment by andrew6...@gmail.com on 27 Jul 2012 at 6:51

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Can the title of this issue be changed to include 
HardwareSerial, Print, Tone

Original comment by jaguar3s...@gmail.com on 28 Aug 2012 at 9:13

GoogleCodeExporter commented 9 years ago
I think it would be better to resolve the actual problems by changing the 
HardwareSerial.cpp code:

line 78 should be: 
  unsigned int i = (unsigned int)(buffer->head + 1) % SERIAL_BUFFER_SIZE;

line 387 should be: 
  unsigned int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE;

Original comment by jeroendoggen on 16 Dec 2012 at 3:01

GoogleCodeExporter commented 9 years ago
Why are the diffs littered with changes from sbi/cbi to sbi8/cbi8, when that 
seems to have nothing to do with the complaint, and sbi8/cbi8 don't seem to be 
defined anywhere?
(sbi/cbi themselves are deprecated)

Casts in general are poor fixes.  if buffer->head is unsigned, it should be 
declared that way.

Original comment by wes...@gmail.com on 17 Dec 2012 at 2:31