[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] cast increases required alignment of target type
From: |
Simon Goldschmidt |
Subject: |
Re: [lwip-users] cast increases required alignment of target type |
Date: |
Wed, 10 Mar 2010 08:27:06 +0100 |
Joe Dupre wrote:
> I've had this warning since v1.3.1. How can I make it go away?
> [..]
> opts = (u32_t *)(seg->tcphdr + 1); <----WARNING: cast increases required
> alignment of target type
> [..]
> This is with arm-elf-gcc (yagarto build 20091018).
> If I understand it correctly, the warning is because seg->tcp_hdr is not
> falling on a 32 bit boundary.
> But I don't know how to correct this.
The problem is that lwIP does not only rely on the compiler's automatic
alignment but takes care of alignment itself. In this case, the tcphdr will
always be aligned because the pbuf's payload pointer is aligned. I just spotted
that warning, too (interesingly, nios2-elf-gcc v3.4.1 only gives me this
warning when compiling as C++, not when compiling as C).
However, I'm curious: this warning should be issued when compiling other files,
too (e.g. sockets.c, mem.c, memp.c), didn't you get those warnings?
Up to now, I think we said "turn off the alignment warning" when compiling the
lwIP code, but at least for gcc, it seems to be enough to add a cast to (void*)
in between. Maybe I'll add that to the code... That way, we are safe to still
get alignement warnings where we didn't explicitly disable them.
Simon
--
Sicherer, schneller und einfacher. Die aktuellen Internet-Browser -
jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/atbrowser