Scratchbox2 returns "Implicit declaration of function getline", among other weird behaviour
Solution 1
Problem solved, all I had to do was add:
#define _GNU_SOURCE
In each header file, before stdio.h was included, very simple really.
I guess this info is assumed known between programmers as i was unable to find it anywhere online, and had to ask my C programming professor personally, and even then we had some trouble tracing the source.
Thanks anyway.
Solution 2
Change your compiler line to include the -E
option and redirect the output. The compiler will only pre-proccess your file when this option is used. Do this for both versions, with and without sb2. getline()
is normally found in stdio.h
. By viewing the preprocessed output from both versions, you should be able to see where getline()
is being included from.
Jaime Borondo
Updated on June 04, 2022Comments
-
Jaime Borondo almost 2 years
I'm trying to cross compile my application for the maemo environment (GNU). When compiling the application normally, everything works fine, however when it's compiled through sb2 the following warning comes up:
$ sb2 gcc -D_GNU_SORCE -o app -Wall -g -I.......//don't think this is relevant In file included from wifi_collector_menu.c:50: wifi_collector_list.c: In function `show_net_apns': wifi_collector_list.c:777: warning: implicit declaration of function `getline'
I am completely confused as to why this happens, there are other getlines that do work in the program, i have tried to define the variable _GNU_SOURCE both inside the code and in the compiler command (not at the same time) This is the line of code which causes the warning apparently:
size_t bytesnum = MAX_ESSID; size_t bytes_read; char *netname = NULL; printf("Enter name of selected network:"); bytes_read=getline(&netname,&bytesnum,stdin);//This line
Any help would be appreciated, thanks in advance.
-
Jaime Borondo over 12 yearsThat shows me several "no newline at end of file" (wich were also showing earlier, but these can be handled easily) as well as a new warning: arm-none-linux-gnueabi-gcc: -lm: linker input file unused because linking not done
-
mpgn over 9 yearsSince glibc 2.10: _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700