#3384: Change int32_t to int ------------------------------+----------------------------- Reporter: Sebastian Huber | Owner: Sebastian Huber Type: enhancement | Status: assigned Priority: normal | Milestone: 5.1 Component: tool/gcc | Version: Severity: normal | Keywords: Blocked By: | Blocking: ------------------------------+----------------------------- Common systems like Linux and FreeBSD define int32_t to int. This means a lot of third party code works well in these cases: {{{ #include <stdint.h>
void f(int32_t); void f(int); void g(int32_t *); void h(void) { int i; g(&i); } }}} On RTEMS you get however in C {{{ test.c:5:6: error: conflicting types for 'f' void f(int); ^ test.c:3:6: note: previous declaration of 'f' was here void f(int32_t); ^ test.c: In function 'h': test.c:12:4: warning: passing argument 1 of 'g' from incompatible pointer type [-Wincompatible-pointer-types] g(&i); ^ test.c:7:6: note: expected 'int32_t * {aka long int *}' but argument is of type 'int *' void g(int32_t *); }}} and C++ {{{ test.c: In function 'void h()': test.c:12:4: error: invalid conversion from 'int*' to 'int32_t* {aka long int*}' [-fpermissive] g(&i); ^~ test.c:7:6: note: initializing argument 1 of 'void g(int32_t*)' void g(int32_t *); ^ }}} This is due to a Newlib speciality which uses long for int32_t if long is a 32-bit type. To ease the use of third party software in RTEMS we should override this option and use int for int32_t just like the standard host operating systems (e.g. Linux and FreeBSD). Only a small GCC patch is required to do this: {{{ diff --git a/gcc/config/rtems.h b/gcc/config/rtems.h index 439199d4cbb..9b1408efe6f 100644 --- a/gcc/config/rtems.h +++ b/gcc/config/rtems.h @@ -48,3 +48,7 @@ -latomic -lc -lgcc --end-group %{!qnolinkcmds: -T linkcmds%s}}}" #define TARGET_POSIX_IO + +/* Use int for int32_t (see stdint-newlib.h). */ +#undef STDINT_LONG32 +#define STDINT_LONG32 0 }}} -- Ticket URL: <http://devel.rtems.org/ticket/3384> RTEMS Project <http://www.rtems.org/> RTEMS Project
_______________________________________________ bugs mailing list bugs@rtems.org http://lists.rtems.org/mailman/listinfo/bugs