| View previous topic :: View next topic |
| Author |
Message |
Shazz

Joined: 31 Aug 2004 Posts: 244 Location: Somewhere over the rainbow
|
Posted: Fri Oct 14, 2005 12:36 am Post subject: stdlib.h & malloc.h : when & why... |
|
|
Usually, while using pspsdk makefiles, including stdlib.h is enough to define malloc and free
But now, as I'm recompiling a portable 3rd party library using generated makefiles, malloc is undefined if malloc.h is not explicitly added (which is not portable, so I had to patch the code)
Can somebody explain me why ?
| Code: |
if psp-gcc -G0 -DHAVE_CONFIG_H -I. -I. -I.. -DHAVE_CONFIG_CONFIG68_H=1 -DNO_FALLBACK_CONFIG=1 -Wall -O3 -fomit-frame-pointer -I/usr/local
/pspdev/psp/sdk/include/libc -I/usr/local/pspdev/psp/sdk/include -I/usr/local/pspdev/psp/include -DHAVE_CONFIG_CONFIG68_H=1 -DNO_FALLBACK_CO
NFIG=1 -Wall -O3 -fomit-frame-pointer -MT word.o -MD -MP -MF ".deps/word.Tpo" \
-c -o word.o `test -f 'word.c' || echo './'`word.c; \
then mv -f ".deps/word.Tpo" ".deps/word.Po"; \
else rm -f ".deps/word.Tpo"; exit 1; \
fi
word.c: In function 'strsav':
word.c:83: warning: implicit declaration of function 'malloc'
word.c:83: warning: incompatible implicit declaration of built-in function 'malloc'
word.c: In function 'delete_word_list':
word.c:96: warning: implicit declaration of function 'free'
/bin/sh ../libtool --mode=link psp-gcc -G0 -I/usr/local/pspdev/psp/sdk/include/libc -I/usr/local/pspdev/psp/sdk/include -I/usr/local/pspdev
/psp/include -DHAVE_CONFIG_CONFIG68_H=1 -DNO_FALLBACK_CONFIG=1 -Wall -O3 -fomit-frame-pointer -L/usr/local/pspdev/psp/sdk/lib -lz -lc -lpsp
libc -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lpsputility -lpspuser -lpspkernel -o as68 as68.o error.o expression.o opcode.o wo
rd.o
|
word.c includes
| Code: |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "as68.h"
|
thanks _________________ - TiTAN Art Division -
http://www.titandemo.org |
|
| Back to top |
|
 |
benji
Joined: 14 Oct 2005 Posts: 17
|
Posted: Fri Oct 14, 2005 2:45 pm Post subject: |
|
|
My first guess would be that it's pulling in the wrong stdlib.h file... try adding the -nostdinc flag to your CFLAGS to eliminate that possibility.
benji |
|
| Back to top |
|
 |
Shazz

Joined: 31 Aug 2004 Posts: 244 Location: Somewhere over the rainbow
|
Posted: Fri Oct 14, 2005 5:12 pm Post subject: |
|
|
Ok found, it was due to this include : -I/usr/local
/pspdev/psp/sdk/include/libc as the pspsdk libc doesn't implement malloc
Is it something missing ? Who's working on the pspsdk libc ? Maybe I can help... _________________ - TiTAN Art Division -
http://www.titandemo.org |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Sat Oct 15, 2005 1:12 am Post subject: |
|
|
| *Sigh*. For any serious use of the ANSI C library, don't use PSPSDK's libc. Use newlib's libc. |
|
| Back to top |
|
 |
71M
Joined: 21 Jun 2005 Posts: 122 Location: London
|
Posted: Sun Oct 16, 2005 3:33 am Post subject: |
|
|
| Is this true for PRX compilation as well? |
|
| Back to top |
|
 |
Shazz

Joined: 31 Aug 2004 Posts: 244 Location: Somewhere over the rainbow
|
Posted: Sun Oct 16, 2005 4:23 am Post subject: |
|
|
It should but it seems newlib libc is not supported by the pspsdk PRX... (see raf posts) _________________ - TiTAN Art Division -
http://www.titandemo.org |
|
| Back to top |
|
 |
|