简体   繁体   中英

implicit declaration of function 'getline' even thought it is

I'm currently having some problems with getline() in c. I know it's not a standard C function, however I am using the proper resources according to what I've seen online.

I have both:

#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

However I am still having problems compiling, it gives me this output:

main.c: In function 'read-file':
main.c:46:17: warning: implicit declaration of function 'getline' [-Wimplicit-function-declaration]
C:\Users\Miguel\AppData\Local\Temp\cc6aYESe.o:main.c:(.text+0x85): undefined reference to `getline'
collect2.exe: error: ld returned 1 exit status

I can't seem to figure out what's wrong, I've seen several problems like this, however no solution seems to apply.

try with the following preprocessor sentence: #define _POSIX_C_SOURCE 200809L

"It allows you to use functions that are not part of the standard C library but are part of the POSIX.1 (IEEE Standard 1003.1) standard. Using the macros described in feature_test_macros allows you to control the definitions exposed by the system header files."

ref: What does #define _POSIX_SOURCE mean?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM