Is this a bug (_ctype_)?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
peeveen
Posts: 1
Joined: Mon Jul 04, 2005 10:35 pm
Location: Glasgow, Scotland

Is this a bug (_ctype_)?

Post by peeveen »

Hi there,
Been experimenting with the PSPSDK, with a view to making some homebrew goodies ...

I wrote a tiny bit of code to test it out, just a main function with a couple of calls to functions from <string.h> and <ctype.h>.

When compiling with psp-gcc, I kept getting linker errors about "undefined reference to _ctype_".

After much headbanging, I realised that if I compile the code with the -O2 compiler switch, it works fine.

As far as I can see, this switch is to do with optimisation. Why would it have this effect?

Apologies if I'm doing something obviously wrong, I'm not really accustomed to this whole unix/toolchain/gnu way of doing things.
User avatar
mc
Posts: 211
Joined: Wed Jan 12, 2005 7:32 am
Location: Linköping

Post by mc »

PSPSDK does not provide a ctype.h of its own, so you are actually using the newlib ctype.h. However, since you are not _linking_ with newlib, the global ctype table used by the header file will not be available.

The reason it works with optimization is probably that the code which actually uses ctype gets optimized away...
Flying at a high speed
Having the courage
Getting over crisis
I rescue the people
Post Reply