all I was compiling a source of my UNIX today when I noticed the following
warning: implicit declaration of function 'clear'
After I made a debug with the GDB on the binary, these came out:
0x090000002a242594 in clear () from /usr/lib/libcurses.a(shr42_64.o)
0x090000002a242600 in wclear () from /usr/lib/libcurses.a(shr42_64.o)
0x090000002a238a80 in werase () from /usr/lib/libcurses.a(shr42_64.o)
0x090000002a238b00 in wmove () from /usr/lib/libcurses.a(shr42_64.o)
0x090000002a238a9c in werase () from /usr/lib/libcurses.a(shr42_64.o)
0x090000002a238600 in wclrtobot () from /usr/lib/libcurses.a(shr42_64.o)
0x090000002a237f80 in wclrtoeol () from /usr/lib/libcurses.a(shr42_64.o)
It seems that it's some kind of a UNIX library "libcurses.a"
How should I include this library in my file in order to get rid of that warning ?
#include <stdlib.h>
#include <curses.h> // See it's here, stop the silly questions
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
Thanks !
From the stacktrace showing shr42_64.o
, your system seems to be some version of AIX, e.g., 5.x for example. Running
ar tv /usr/lib/libcurses.a
would show something like
r--r--r-- 2/2 493219 Aug 05 05:38 2011 shr42.o
r--r--r-- 2/2 377211 Aug 05 05:38 2011 shr4.o
r--r--r-- 2/2 194484 Aug 05 05:38 2011 shr.o
The corresponding header /usr/include/curses.h
has the prototype for clear()
ifdef'd within
#if defined(NOMACROS) || defined(lint)
#if defined(__STDC__) || !defined(_NO_PROTO)
and (assuming your compiler really uses that header) the latter line is what is used. From the comment about gdb
, it seems likely that you also are using gcc
. Usually gcc
will define __STDC__
(though some very old port may not). If there is no problem with that definition, it is possible that something defined _NO_PROTO
. Alternatively, your system could have some conflicting header file. To resolve what is the case, I would generate the preprocessor-output file (using options -E
, -P
and -C
as documented) and look to see which "curses.h" file was included, and which ifdef was actually used.