Page MenuHome GnuPG

pinentry: Fix -Wimplicit-function-declaration warning in pinentry-curses.c [patch]
Closed, ResolvedPublic


Compilation yields the following warning. When -Werror is enabled, this causes
the build to fail.

x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I.. -I../secmem -Wall -g -O2
-Wall -Wno-pointer-sign -Wpointer-arith -c -o pinentry-curses.o pinentry-curses.c
pinentry-curses.c: In function ‘dialog_create’:
pinentry-curses.c:466:8: warning: implicit declaration of function ‘addnwstr’

        ADDCH (start[i]);

Reason seems to be that the wrong curses.h header file is included when cursesw
is used.

Proposed solution:
Include the ncursesw/curses.h header file when using ncursesw.

  • pinentry-0.9.7-unpatched/pinentry/pinentry-curses.c 2015-06-30

10:30:16.000000000 +0200
+++ pinentry-0.9.7-patched/pinentry/pinentry-curses.c 2016-04-16
09:07:09.027429582 +0200
@@ -22,7 +22,11 @@
#include <config.h>
#include <assert.h>
+#include <ncursesw/curses.h>
#include <curses.h>
+#endif /*HAVE_NCURSESW*/
#include <signal.h>
#include <fcntl.h>
#include <unistd.h>

Event Timeline

gupsgr raised the priority of this task from Low to Normal.Apr 16 2016, 9:12 AM
gupsgr added projects: pinentry, Bug Report.
gupsgr added a subscriber: gupsgr.
werner lowered the priority of this task from Normal to Low.Apr 20 2016, 9:03 AM

What operating system are you using?

We had the exact same patch committed (21e83f42) and later reverted (f0db3192).

What operating system are you using?

I'm using Gentoo.

(referring to the discussion you linked):

pkg-config ncursesw --cflags returns "-I/usr/include/ncursesw", which is the
correct path. However, this include is not listed in the gcc command line (see
initial message).

I'm no expert in make nor autotools, but looking at pinentry/Makefile $COMPILE
uses $INCLUDES and $AM_CPPFLAGS. However $INCLUDES is not defined and
$AM_CPPFLAGS only adds -I../secmem. Also, nothing seems to use the variable
$NCURSES_INCLUDE (which is set to the pkg-config value "-I/usr/include/ncursesw").

This leads me to the wild guess that the pkg-config definitions for ncurses are
ignored by configure (or however sets up the Makefile). Instead the default
include directory /usr/include is used which has the wrong curses.h header. I
would like to submit a patch, but I sadly have no knowledge about make and automake.

Can you please test if the following patch that has been committed recently
fixes your problem?

(It is not NCURSES_INCLUDE, but NCURSES_CFLAGS should be set by


Can you please test if the following patch that has been committed recently

fixes your problem?;a=commitdiff;h=2227f67af53f38d3d7f97760f2553d2c9ed05969

Cloning the git repository (commit id 2227f67af53f38d3d7f97760f2553d2c9ed05969)
followed by
./configure --enable-maintainer-mode

works, i.e. the warning/error is not present any more.
So this patch seems to fix the issue.

The command line for gcc backs this observation (note the includes):

gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/include/ncursesw -I../pinentry -Wall -g
-O2 -Wall -Wcast-align -Wshadow -Wstrict-prototypes -Wformat -Wno-format-y2k
-Wformat-security -W -Wno-sign-compare -Wno-missing-field-initializers -Wdeclaratio
n-after-statement -Wno-pointer-sign -Wpointer-arith -MT pinentry-curses.o -MD
-MP -MF .deps/pinentry-curses.Tpo -c -o pinentry-curses.o pinentry-curses.c