forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

stdlib.h & malloc.h : when & why...

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Shazz



Joined: 31 Aug 2004
Posts: 244
Location: Somewhere over the rainbow

PostPosted: Fri Oct 14, 2005 12:36 am    Post subject: stdlib.h & malloc.h : when & why... Reply with quote

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
View user's profile Send private message Visit poster's website
benji



Joined: 14 Oct 2005
Posts: 17

PostPosted: Fri Oct 14, 2005 2:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
Shazz



Joined: 31 Aug 2004
Posts: 244
Location: Somewhere over the rainbow

PostPosted: Fri Oct 14, 2005 5:12 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Sat Oct 15, 2005 1:12 am    Post subject: Reply with quote

*Sigh*. For any serious use of the ANSI C library, don't use PSPSDK's libc. Use newlib's libc.
Back to top
View user's profile Send private message
71M



Joined: 21 Jun 2005
Posts: 122
Location: London

PostPosted: Sun Oct 16, 2005 3:33 am    Post subject: Reply with quote

Is this true for PRX compilation as well?
Back to top
View user's profile Send private message
Shazz



Joined: 31 Aug 2004
Posts: 244
Location: Somewhere over the rainbow

PostPosted: Sun Oct 16, 2005 4:23 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group