When code is compiled with C99, it conforms to the C99 standard, which does not have stricmp() . When code is compiled without a C99 switch, it conforms to an unknown standard that implements stricmp() . (Given gcc without -std=c99 , the C89 / 90 standard is likely to compile, allowing for implicit declarations.)
As @Joachim Pileborg notes , insensitive comparisons are not part of the C standard.
Using C99 for implicit functions requires diagnostics (warning in this case). Without C99, implicit use of a function does not generate any warnings. Functions exist in this compiler library - we are talking only about functions declared before use.
Easy enough to make your own:
int wal_stricmp(const char *a, const char *b) { int ca, cb; do { ca = (unsigned char) *a++; cb = (unsigned char) *b++; ca = tolower(toupper(ca)); cb = tolower(toupper(cb)); } while (ca == cb && ca != '\0'); return ca - cb; }
Note. When coding and trying to make AZ match AZ , string methods for checking for unevenness work equally well. But when trying to order strings, things quickly get out of hand. "abc" vs. "_bc" may appear before or after another, depending on whether compassion was done as upper or lower case. '_' , in ASCII, exists between uppercase and lowercase letters. In the context of internationalization and localization, the situation becomes more complicated. My code example uses reverse conversion to deal with problems when the number of capital letters char does not match 1 to 1 with lowercase. IMO The complexity of strong case-insensitive errors requires the use of UTF encoding and the determination of its case.
source share