Efficient STRing CoMPares?

Marc Auslander marc at arnor.UUCP
Wed Mar 20 23:02:39 AEST 1991


A correct compiler cannot inline strcmp unless it is given
extralingual permission to do so - for example in a pragma or by
defining some reserved symbol or by some other means.  This is because
it is legal to combine a program which uses strcmp with another which
defines it to by anything at all!

For example, the Risc System/6000 xlc compiler inlines __strcmp and
__strcpy.  (In Ansi C, its ok for the compiler to do funny things with
symbols which start with "__").  Then, string.h contains defines of
strcmp and strcpy to the __ versions which are done if __STR__ is
defined.  From the user point of view, you define __STR__ if you want
in line string functions.  On user approach is to add -D__STR__ to the
CFLAGS in his make file.

(If you're going to the trouble of inlining, its a good idea to do it
in a way which lets you get the advantage in benchmarks!)

--


Marc Auslander       <marc at ibm.com>



More information about the Comp.lang.c mailing list