diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-06-14 05:10:51 +0000 |
---|---|---|
committer | Sebastian Huber <sh@gcc.gnu.org> | 2018-06-14 05:10:51 +0000 |
commit | c7a42ade9befecb8fca501b5e2021c09496f3554 (patch) | |
tree | b915059a6f91eee0fe174840e0847df844807319 /gcc | |
parent | 6c07e43960978c4dcd83ba92a91a547c673f2cc2 (diff) | |
download | gcc-c7a42ade9befecb8fca501b5e2021c09496f3554.zip gcc-c7a42ade9befecb8fca501b5e2021c09496f3554.tar.gz gcc-c7a42ade9befecb8fca501b5e2021c09496f3554.tar.bz2 |
RTEMS: Prefer int for int32_t
Common systems like glibc 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 got 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 was 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
override this Newlib option now and use int for int32_t if int is a
32-bit type.
gcc/
* config/rtems.h (STDINT_LONG32): Define.
From-SVN: r261582
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/config/rtems.h | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8c655bd..ceb0d66 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2018-06-14 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * config/rtems.h (STDINT_LONG32): Define. + 2018-06-13 Matthew Fortune <matthew.fortune@mips.com> Prachi Godbole <prachi.godbole@imgtec.com> diff --git a/gcc/config/rtems.h b/gcc/config/rtems.h index dcea95c..af58eb1 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 + +/* Prefer int for int32_t (see stdint-newlib.h). */ +#undef STDINT_LONG32 +#define STDINT_LONG32 (INT_TYPE_SIZE != 32 && LONG_TYPE_SIZE == 32) |