Hi,
I added -Werror to the Makefile and I noticed these (I'm building for 328p):
[font=Courier New]Compiling C: ../ChibiOS/os/rt/src/chstats.c
avr-gcc -c -mmcu=atmega328p -I. -gdwarf-2 -DF_CPU=16000000UL -O2 -funsigned-char -fdata-sections -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wundef -Werror -Wunreachable-code -Wsign-compare -Wa,-adhlns=./../ChibiOS/os/rt/src/chstats.lst -I../ChibiOS/os/common/ports/AVR -I../ChibiOS/os/common/ports/AVR/compilers/GCC -I../ChibiOS/os/rt/include -I../ChibiOS/os/common/oslib/include -I../ChibiOS/os/hal/include -I../ChibiOS/os/hal/osal/rt -I../ChibiOS/os/hal/ports/AVR -I../ChibiOS/os/hal/boards/SPARKFUN_PRO_MICRO -I../ChibiOS/os/license -I../ChibiOS/os/various -I../lib -I../lib/motors -std=gnu11 -MMD -MP -MF .dep/chstats.o.d ../ChibiOS/os/rt/src/chstats.c -o ../ChibiOS/os/rt/src/chstats.o
In file included from ../ChibiOS/os/rt/include/ch.h:81:0,
from ../ChibiOS/os/rt/src/chthreads.c:51:
../ChibiOS/os/rt/src/chthreads.c: In function 'chThdCreateSuspendedI':
../ChibiOS/os/common/ports/AVR/chcore.h:265:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
tp->ctx.sp->r2 = (uint8_t)(pf); \
^
../ChibiOS/os/rt/src/chthreads.c:190:3: note: in expansion of macro 'PORT_SETUP_CONTEXT'
PORT_SETUP_CONTEXT(tp, tdp->wbase, tp, tdp->funcp, tdp->arg);
^
../ChibiOS/os/common/ports/AVR/chcore.h:267:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
tp->ctx.sp->r4 = (uint8_t)(arg); \
^
../ChibiOS/os/rt/src/chthreads.c:190:3: note: in expansion of macro 'PORT_SETUP_CONTEXT'
PORT_SETUP_CONTEXT(tp, tdp->wbase, tp, tdp->funcp, tdp->arg);
^
../ChibiOS/os/common/ports/AVR/chcore.h:270:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
tp->ctx.sp->pch = (uint8_t)_port_thread_start; \
^
../ChibiOS/os/rt/src/chthreads.c:190:3: note: in expansion of macro 'PORT_SETUP_CONTEXT'
PORT_SETUP_CONTEXT(tp, tdp->wbase, tp, tdp->funcp, tdp->arg);
^
../ChibiOS/os/rt/src/chthreads.c: In function 'chThdCreateStatic':
../ChibiOS/os/common/ports/AVR/chcore.h:265:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
tp->ctx.sp->r2 = (uint8_t)(pf); \
^
../ChibiOS/os/rt/src/chthreads.c:358:3: note: in expansion of macro 'PORT_SETUP_CONTEXT'
PORT_SETUP_CONTEXT(tp, wsp, tp, pf, arg);
^
../ChibiOS/os/common/ports/AVR/chcore.h:267:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
tp->ctx.sp->r4 = (uint8_t)(arg); \
^
../ChibiOS/os/rt/src/chthreads.c:358:3: note: in expansion of macro 'PORT_SETUP_CONTEXT'
PORT_SETUP_CONTEXT(tp, wsp, tp, pf, arg);
^
../ChibiOS/os/common/ports/AVR/chcore.h:270:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
tp->ctx.sp->pch = (uint8_t)_port_thread_start; \
^
../ChibiOS/os/rt/src/chthreads.c:358:3: note: in expansion of macro 'PORT_SETUP_CONTEXT'
PORT_SETUP_CONTEXT(tp, wsp, tp, pf, arg);
^[/font]
Assuming the upper byte is empty and can be disregarded, this patch fixes the warning.
Size cast errors in the AVR port Topic is solved
Moderator: tfAteba
Re: Size cast errors in the AVR port
Patch applied! Btw, it only fixes the warnings for two-byte sized PC AVRs (which excludes basically the ATmega2560). I will check that one tomorrow and re-apply the changes on it.
Cheers,
Fabio Utzig
Cheers,
Fabio Utzig
Re: Size cast errors in the AVR port
utzig wrote:Patch applied! Btw, it only fixes the warnings for two-byte sized PC AVRs (which excludes basically the ATmega2560). I will check that one tomorrow and re-apply the changes on it.
Cheers,
Fabio Utzig
Yes, probably I left that out, sorry. As I wrote in another post, I use only 328p, so that's the only target I could test.