Jens
Jens

Reputation: 72727

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?

Upvotes: 6

Views: 194

Answers (2)

Thomas Dickey
Thomas Dickey

Reputation: 54583

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)

Upvotes: 1

Iharob Al Asimi
Iharob Al Asimi

Reputation: 53016

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

Upvotes: 5

Related Questions