avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Re: Problem with avr gcc compiler ? No warning of mixedda


From: David Brown
Subject: [avr-gcc-list] Re: Problem with avr gcc compiler ? No warning of mixeddata types
Date: Sun, 19 Apr 2009 21:41:55 +0200
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

Weddington, Eric wrote:


-----Original Message----- From: address@hidden [mailto:address@hidden org]
On Behalf Of Dan Roganti Sent: Sunday, April 19, 2009 9:26 AM To:
address@hidden Subject: [avr-gcc-list] Problem with avr
gcc compiler ? No warning of mixeddata types


Eventually, we noticed a problem with the data types getting mixed,
the adc value is stored in a uint16_t variable and the array which
holds all the readings was a uint8_t variable. This obviously
mashed all the readings into something unreliable. This is
something we should have noticed, but _also _ something that the
*compiler* should have noticed !

It could be that you do not have such warnings enabled. You didn't
post what compiler settings you were using...


You didn't post your compiler settings, as requested by Eric. If you had, someone (such as Eric, or me) would quickly point out that you need appropriate warning flags to catch such conditions that are considered perfectly legal C code (blame the C standards, not the compiler!). In this case, you need the -Wconversion flag give a warning.

It looks like you've also emailed Eric off-list, rather than keeping to the list. I know it is easy to do this by mistake, but try not to - keeping it on-list means that more people can help (and let Eric spend more time on the compiler and library, rather than support), and it means that other people can benefit from the solutions.

To help for the future, here are the warning flags I use (I think I've posted these before):

-Wall -Wextra -Wunreachable-code -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wconversion

This is almost all the compiler's warning flags, but I skip a few because of too many false positives. That list is for gcc 4.3 - when avr-gcc 4.4 is ready, I'll probably have a few more to add.

mvh.,

David





reply via email to

[Prev in Thread] Current Thread [Next in Thread]