The stdio library distributed with glibc
declares a function that is also called getline
with a different signature than yours. Since you cannot declare two functions with the same name the compiler gives an error. The conflicting declaration of getline
found in stdio.h is:
ssize_t getline(char **lineptr, size_t *n, FILE *stream);
The getline
function was originally a glibc extension, and has then been included in POSIX.1-2008. It is not a standard C function.
If you are using gcc
you can get standards-compliant behavior by using the -std
command line switch. Among other things this hides declarations of non-standard functions. Try for example:
gcc -Wall -pedantic -std=c11 "section 1.9.1.c" -o "section 1.9.1"