0

I have tried to run the functions "strlwr", "strupr", "strcmpi", "strrev" from the string.h under Ubuntu and the gcc compiler; getting the next message:

warning: implicit declaration of function ‘strupr’ [-Wimplicit-function-declaration]

as well

(.text+0x84): undefined reference to `strupr'

Once I tried over Windows, same compiler, everything works perfectly.

I looked over the string.h in linux under "/usr/include" which states that was part of the GNU C library ISO C99 7.21 string handling (also tried to compile with the -std=c99, din't work) and I've learned from the header file that I could use the "strcasecmp" function, instead of the "strcmpi".

Can not do the same in Windows (look under the code of the header file) since the headers and libraries files are kind embedded under the compiler code, Am I right?(1)

Again searching for the string.h file in Linux, I have found nearly 50 files with the same name under different paths such as /usr/include/linux; /usr/include/x86-64-linux-gnu/bits others under the directories of Oracle VB and the Arduino directory. Why are so many files that handle the strings in C but doing in different fashion? How does the compiler knows which one to take in order to do the work? Is there any way, under the C file or during the compile process to define one of the multiple headers files?(2)

Am I using out of date headers and libraries, Is there any "official" source to know if any library have come depreciated? How to know what are under the Windows headers and libraries?(3)

gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.5) is what I am using and Windows 8.

  • 3
    Here is the *standard* definition of what is supposed to be in `string.h`: http://port70.net/~nsz/c/c11/n1570.html#7.24 None of the mentioned functions is there, so consider them as provided as a courtesy by some compilers. – Eugene Sh. Dec 07 '17 at 19:32
  • The ones under `/usr/include/x86...` are for compiling the kernel. – Barmar Dec 07 '17 at 19:35
  • 1
    Related: https://stackoverflow.com/questions/26327812/strupr-and-strlwr-in-string-h-part-are-of-the-ansi-standard Also: https://stackoverflow.com/questions/9618697/is-the-function-strcmpi-in-the-c-standard-libary-of-iso – Bob__ Dec 07 '17 at 20:05
  • 3
    That is why you should use C standard functions – Erik W Dec 07 '17 at 20:07
  • 1
    The POSIX analogue of `strcmpi()` is [`strcasecmp()`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/strcasecmp.html), declared in ``, and there's `strncasecmp()` too — and variants that take a specific locale for doing the comparison in. Functions that aren't defined by standard C are not necessarily available everywhere. If you want to use functions not defined by standard C, you have to be prepared to provide declarations and implementations for use on platforms where they're not available, or rewrite your code to use only what's available in standard C. – Jonathan Leffler Dec 07 '17 at 21:55

0 Answers0