[sword-devel] 1.5.3 + optimizations

David White sword-devel@crosswire.org
19 Feb 2002 20:20:52 +1100

This is likely because in C++, all C runtime functions (isalpha,
isdigit, strcmp, strncpy and so on and so forth) are meant to be in the
std namespace, rather than in the global namespace. So, you have to use
std::isalpha instead of isalpha (and likewise for all C runtime

Many C++ compilers, including gcc didn't implement this for a long time.
gcc has only just implemented it in 3.0, and MSVC++ still doesn't,
although likely will in the next version.

This is a fairly difficult problem to solve elegantly (Note that using
the declaration "using namespace std;" is *not* elegant :), since the
code will be expected to compile on both types of compilers (although
note that lots of older-style compilers have std:: as a synonym for ::,
so the newer solution should work with them anyway; however I don't
think this holds for MSVC++. A good article on the topic can be found at
http://www.gotw.ca/gotw/053.htm although it deals largely with code that
isn't expected to work on both kinds of compilers.

Of course, the problem can largely be side-stepped by using C++-style
functions instead of C style functions, which are more typesafe and
generally better style (imho of course :) than their C equivalents. Of
course, some C-style functions such as those declared in ctype have no
C++ equivalent.



On Tue, 2002-02-19 at 18:55, David Blue wrote:
> On Wednesday 13 February 2002 06:48 pm, you wrote:
> > Hello all,
> > 	If there is anything else pressing that anyone wants to get in, please
> > send me a patch soon, or suggest it here on the list and see if anyone
> > is willing to do it.
> Not so much as code that needs to go in but will 1.5.3 be compatible with 
> gcc3? I've got a system that lets me swap back and forth between gcc3.0.3 and 
> gcc2.96 and sword 1.5.2 refuses to compile under gcc3 it can't find the 
> prototypes for the isalpha function or some such thing. I can produce the 
> exact error if you need it. I know it's not just my system however, since it 
> sucessfully compiles under gcc2.96 (though I can't compile chetah with gcc3 
> if it is apparently ;_;) Oh, and in gcc3 the -m486 switch is deprecated and 
> now uses -march=ix86 (x can be 3-6) or -mcpu=ix86.