Crosscompile & strndup()

John Tytgat John.Tytgat at
Wed Jun 5 18:38:39 PDT 2002


I've just tried to do my first steps in cross compiling GCC.  The copy
comes straight of CVS repo selecting the release_2_95 branch.  The compile
box is a Debian x86 potato 2.2r6 system.

The problem I had was the strndup() definition in gccsdk/riscos-aof/as/os.h
and gccsdk/riscos-aof/as/strdup.c as strndup() is defined in
/usr/local/string.h locally but isn't in UnixLib headers.

] /* Return a malloc'd copy of at most N bytes of STRING.  The
]    resultant string is terminated even if no null terminator
]    appears before STRING[N].  */
] #if defined __USE_GNU
] extern char *strndup __P ((__const char *__string, size_t __n));
] #endif

Instead of the original "#ifndef strndup" test in os.h & strdup.c, I've
changed this into "#ifndef CROSS_COMPILE" but I consider this as a big
hack.  I would assume this better needs to be done via configure, no ?

Anyway patch attached but I'm sure people will suggest a better solution.

Apart from that, everything seems to work fine.  I'm very impressed. :-]

John Tytgat, in his comfy chair at home                                 BASS
John.Tytgat at                             ARM powered, RISC OS driven
-------------- next part --------------
Index: riscos-aof/as/os.h
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/as/os.h,v
retrieving revision
diff -u -r1.3.2.3 os.h
--- riscos-aof/as/os.h  30 Mar 2002 09:48:24 -0000
+++ riscos-aof/as/os.h  6 Jun 2002 01:23:08 -0000
@@ -57,7 +57,7 @@
 #endif /* __riscos__ */
 char *CanonicaliseFile (const FILE * path);
-#ifndef strndup
 char *strndup (const char *, int len);
Index: riscos-aof/as/strdup.c
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/as/strdup.c,v
retrieving revision
diff -u -r1. strdup.c
--- riscos-aof/as/strdup.c      1 Mar 2002 16:48:22 -0000
+++ riscos-aof/as/strdup.c      6 Jun 2002 01:23:08 -0000
@@ -8,7 +8,7 @@
 #include "os.h"
 #include "error.h"
-#ifndef strndup
 char *
 strndup (const char *str, int len)

More information about the gcc mailing list