[Proj] Modern C functions

Frank Warmerdam warmerdam at pobox.com
Thu Feb 26 11:18:37 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?

Gerald,

My experience has been that all POSIX environments have these functions, but
that Win32 (aka MSVC) instead uses strnicmp() and stricmp() to do the same
thing.  I've lived with macros like:

#ifndef EQUAL
#if defined(WIN32) || defined(WIN32CE)
#  define EQUALN(a,b,n)           (strnicmp(a,b,n)==0)
#  define EQUAL(a,b)              (stricmp(a,b)==0)
#else
#  define EQUALN(a,b,n)           (strncasecmp(a,b,n)==0)
#  define EQUAL(a,b)              (strcasecmp(a,b)==0)
#endif
#endif

so I'm not sure if the situation has improved with recent MSVC releases.

These functions have been a classic win32/unix porting hassle for two
decades.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the Proj mailing list