Ci0‐libft - rciak/42-eva-lua GitHub Wiki
The subsequent relies on what I believe is true - but there is no guarantee that I did not misunderstood something. If you feel that there is something not correct below, please feel free to contact me (42 login name: reciak). Any corrections are appreciated.
The enumeration is just for easier reference when communicating with other human beings.
-
Why should
libft.hbe included in all*.cfiles although the compiler should work even without doing so?
It is less error prone:- When
file.cgets compiled tofile.othe compiler will notice a type mismatch between prototype and function definition. --> A danger less that the linker will create a wrongly assembled program producing undefined behavior.
- When
-
Why do functions like
int isalnum(int c); int isalpha(int c);
expect an integer and not an unsigned char?
When taking the following into account
cat /usr/include/stdio.h | grep -B 2 -A 4 "#define.*EOF"the answer is contained in the man page for
isalpha:These functions check whether c, which must have the value of an unsigned char or EOF,Assumed Historical background: Before Unicode started ruling, the original ASCII set (values 0,... 127), using only 7 bits of the 8 ones available in a char variable, used to be complemented in different ways, depending on the laguage in use. To see the effect run the following C Programm in two different Terminal encoding settings, e.g. once in UTF-8 (Unicode Transformation Format - 8-bit) and once in IBM862 (Hebrew - one choice of many extended ASCII codes)
#include <stdio.h> int main() { unsigned char c; c=0; while (c < 255) { printf("%hhu: %c \n", c, c); c++; } return 0; }
I assume that
isalpha(128)(with 128 standing for the first hebrew letter "ALEPH" in the above Hebrew locale) should return 1 / true if systemwide such an old character encoding would be active. -
What is the meaning the options
r,candsinar -rcs?-
nm -s libft.aprints the symbol table.
-