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

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

Re: [avr-gcc-list] New GCC warning - how to silence?


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] New GCC warning - how to silence?
Date: Fri, 6 Apr 2007 23:02:06 +0200
User-agent: Mutt/1.5.11

As larry barello wrote:

> Are you just saying use either signed or unsigned (I typically use
> uint8_t except when the signedness counts) or is "char" a distinct
> type that has defined behavior across portable systems?

char is always either signed or unsigned, but as a portable
application must not make assumptions about char's signedness, you
always need to use explicit typecasts when converting between each of
them.

> Anyway, I solved the warnings by casting (or changing the type) of
> buffers and pointers from "uint8_t" to "char" ...

Which is thus just the right thing to do.


As Eric Weddington wrote:

> Probably another candidate for the FAQ, as more users move to GCC
> 4.x.

Yes, fine with me.


As Eric Weddington wrote:

> Dmitry wrote:

> > It is interesting, what was a reason to declare
> > default char as signed for AVR port?

Right now, there *is* a reason: consistency.  We've always had it that
way.

> > Many other GCC ports use unsigned.

I guess Denis "inherited" it from the i386 port that also defaults to
signed chars.

> So this means that the AVR defaults to a signed char. Can we change
> this to be unsigned?:

Please don't.  Consistency is more important now.  This change might
have been appropriate about 7 years ago.

> For that matter, can we also define this target hook:

> TARGET_DEFAULT_SHORT_ENUMS

> And have it return true?

Rather not.  You can always force an enum to its shortest form by
using __attribute__((packed)), but there's nothing like
__attribute__((nopacked)) which you could use to turn the enum into an
int type when it defaults to a smaller size.

We should probably hint about the __attribute__((packed)) thing in the
documentation though.  Yet another FAQ entry?

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)




reply via email to

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