making sscanf() & sprintf() work
James Youngman
JYoungman@vggas.com
Tue May 26 04:18:00 GMT 1998
>>>>> "pmi" == Peer Moeller Ilsoe <ilsoe@kom.auc.dk> writes:
pmi> I want thank everyone who responded to my double <-> string
pmi> conversion problem. It seems that sscanf() and sprintf() do the
pmi> job just fine -at least on our unix machines. Now when I try to
pmi> cross-compile with the newlib 1.8 libraries (libm, libc, and
pmi> libgcc) the linker goes:
pmi> makebuf.c:93: undefined reference to `isatty'
pmi> sbrkr.c:61: undefined reference to `sbrk'
pmi> fstatr.c:61: undefined reference to `fstat'
pmi> readr.c:58: undefined reference to `read'
pmi> lseekr.c:58: undefined reference to `lseek'
pmi> writer.c:58: undefined reference to `write'
pmi> closer.c:53: undefined reference to `close'
pmi> Can anybody tell me weather I have to write these functions
pmi> myself or are they already implemented somewhere? Can they be
pmi> stubbed out if I'm not going to use any kind of std I/O? What
pmi> should the functions do if they can't be stubbed out? I just
pmi> need a minimal system, which will make the conversion work.
Using the stdio functionality will bring in references to those
components that it relies on -- the underlying OS interface. You have
to attach it to those functions, or stub them out with something like:-
/* typedef long off_t; */
/* typedef long ptrdiff_t; */
/* Most things return failure.
*/
int isatty(int fd) { return 0; }
int fstat(int fd, struct stat *p) { return -1; }
int read(int fd, void *p, size_t n) { return 0; }
int write(int fd, void *p, size_t n) { return 0; }
off_t lseek(int fd, off_t offset, int whence) { return -1; }
/* close() will succeed for std{in,out,err}
*/
int close(int fd) { return (fd < 3) ? 0 : -1; }
/* Memory allocation: this you really DO have to write, I think.
*/
void *sbrk(ptrdiff_t increment)
{
#error WRITE ME
}
More information about the crossgcc
mailing list