Convert string to lower case in C
09/12/2017 10:19
Hi All, I'm using GCC 3.4.6 and am encountering a link error (symbol not found: __ctype_lower) with the following code (specifically, the line with tolower in): char *lower_case(char *s) { char *ret = s; if (s) { while (*s) { if (*s > 0) *s = tolower(*s); s++; } } return ret; } What's going wrong? Thanks, Adam -- Adam Richardson Carpe Diem http://www.snowstone.org.uk/riscos/

Source is Usenet: comp.sys.acorn.programmer
Sign in to add a comment

Answer score: 5
09/12/2017 10:19 - In message <62e79cdd4e.rik-news@iyonix.elements>, Rik Griffin wrote: Sorry, I should have said that I've included the line: #include <ctype.h> and that I'm compiling using -mlibscl Adam -- Adam Richardson Carpe Diem http://www.snowstone.org.uk/riscos/

Source is Usenet: comp.sys.acorn.programmer
Sign in to add a comment

Answer score: 5
09/12/2017 10:19 - In message <8df19fdd4e.admin@snowstone.org.uk> Adam <news@snowstone.org.uk> wrote: Perhaps not too helpful but this compiles here with the Castle Tools and gcc with either the clib or unixlib.

#include <stdio.h> #include <ctype.h> char *lower_case(char *s); int main(void) { } char *lower_case(char *s) { char *ret = s; if (s) { while (*s) { if (*s > 0) *s = tolower(*s); s++; } } return ret; } -- David Pitt.

Computing with RISC OS.


Source is Usenet: comp.sys.acorn.programmer
Sign in to add a comment

Answer score: 5
09/12/2017 10:19 - In message <761b9bdd4e.admin@snowstone.org.uk> Adam <news@snowstone.org.uk> wrote: I think you're linking with the wrong version of the standard library. Or possibly using the wrong version of the <ctype.h> header file.

tolower() is implemented as a macro, the macro uses an array (I think) called __ctype_lower, clearly that variable isn't exported by the library you are linking with.

-- Rik Griffin Standard disclaimer, not speaking for anyone but myself, blah blah (Reply-To may be broken: use rik dot griffin at denbridge marine dot com)

Source is Usenet: comp.sys.acorn.programmer
Sign in to add a comment

Answer score: 5
09/12/2017 10:19 - In message <6a06a1dd4e.pittdj+@pittdj.plus.com>, David Pitt wrote: Sigh. Yes, your sample compiles OK here too. So I've just spent the best part of two hours trying to work out what the differences are in my two test cases. Experimenting with -mlibscl (and the lack of it) did seem to reveal some results, but I still couldn't work out what was wrong. In the end, in a fit of desperation, I re-compiled everything in the project from scratch and lo and behold it links OK now! Presumably some other source file in my project had at some point been compiled without the -mlibscl switch and that was causing the wobbly when I tried to link my test case to everything else.

So all in all, a bit of a waste of everyone's time. Sorry about that.

Adam -- Adam Richardson Carpe Diem http://www.snowstone.org.uk/riscos/

Source is Usenet: comp.sys.acorn.programmer
Sign in to add a comment

eDiscover
Helpforce eDiscover provides technical articles updated each dayHelpforce eDiscover RSS feed contains the latest technical articles in RSS
Click the logo to go back to the main page
Search eDiscover
  
Categories

Click an icon to go to that category

Helpforce eDiscover contains articles about Microsoft Windows Helpforce eDiscover contains articles about Apple products and MacOS Helpforce eDiscover contains articles about Linux and POSIX operating systems Helpforce eDiscover contains articles about Helpforce Helpforce has a large variety of technical information and articles for you to read Helpforce eDiscover contains articles about databases, MYSQL, SQL Server Oracle Helpforce eDiscover contains articles about Java, JVM and the JRE Helpforce eDiscover contains articles about the QNX operating system Helpforce eDiscover contains articles about Oracle Solaris and Open Solaris Helpforce eDiscover contains articles about RISC OS, Acorn and the BBC Micro Helpforce eDiscover contains articles about Amiga and AmigaOS

Type your comment into the box below