[Proj] Modern C functions

Glynn Clements glynn at gclements.plus.com
Thu Feb 26 22:31:58 EST 2009


Gerald I. Evenden wrote:

> This is a quick probe of the programming types in this group.
> 
> In finalizing Rel. 2.0 of geodesic and libgeodesy I ran across functions under 
> the <string.h> heading which are not in the typical (read Harrison & Steele) 
> library references: strcasecmp and strncasecmp.  These are noted in the Gnu 
> man.3 as Posix 2001 standard routines.  Obviously, these two routines replace 
> strcmp and strncmp and make comparisons case independent.
> 
> As soon as I became aware of them I have included them to eliminate the nasty, 
> nasty fact of having to shift when typing in WGS84 and can now use 
> ellps=wgs84.
> 
> A little net browsing has yielded mixed results as to how well know these 
> functions are.
> 
> Thus my question here is: do non-Gnu C compilers used by this audience 
> recognize these functions?

It's not an issue for the compiler, but for the standard library.

The are specified by POSIX, but not by ANSI C (neither C89 nor C99).

As others have already pointed out, Windows doesn't provide them. 
Also, gcc won't recognise them if you use -ansi and don't explicitly
add the POSIX feature macros, e.g. -D_POSIX_SOURCE. I don't know
whether uclibc has them.

Also, bear in mind that the behaviour depends upon the locale; using
them for strings containing anything other than alphanumeric
characters is problematic.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the Proj mailing list