Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a narrow prototype and why would I need one?

While compiling xterm I came across a configure option named

--enable-narrowproto    enable narrow prototypes for X libraries

(The negation of this option is required to make the scrollbar work under Cygwin, along with --disable-imake.)

I know that in K&R C prototypes didn't exist and all arguments smaller than int or double underwent promotions. Searching the ISO C99 Standard came up empty. What exactly is a narrow prototype? Is there a wide prototype for symmetry? What potential problem arises if I don't use a narrow prototype?

like image 222
Jens Avatar asked Jan 25 '15 14:01

Jens


2 Answers

The NARROWPROTO macro is used in Xfuncproto.h to define another macro

#ifdef NARROWPROTO
#define NeedWidePrototypes 0
#else
#define NeedWidePrototypes 1        /* default to make interropt. easier */
#endif

NeedWidePrototypes which is in turn used in Xlib.h for example in the following way

extern XModifierKeymap  *XInsertModifiermapEntry(
    XModifierKeymap*    /* modmap */,
#if NeedWidePrototypes
    unsigned int    /* keycode_entry */,
#else
    KeyCode     /* keycode_entry */,
#endif
    int         /* modifier */
);

KeyCode is a typedef from X.h

typedef unsigned char KeyCode;

so I guess narrow here, referes to the width of the type used for KeyCode.

The same construct for the same typedef can be found in other files, for example XKBlib.h

like image 76
Iharob Al Asimi Avatar answered Sep 24 '22 00:09

Iharob Al Asimi


Besides being noted in INSTALL, it was also an FAQ, topical for a few years Why doesn't the scrollbar work? (also see the notes in the change-log during 2006)

like image 30
Thomas Dickey Avatar answered Sep 25 '22 00:09

Thomas Dickey