What is a narrow prototype and why is it needed?

When compiling xterm, I came across a configure option called

--enable-narrowproto enable narrow prototypes for X libraries 

(Denying this option is required to make scrolling work under Cygwin along with --disable-imake .)

I know that there were no prototypes in K & RC, and all arguments smaller than int or double were exposed to promotions. The search for the ISO C99 standard was empty. What is a narrow prototype? Is there a broad prototype for symmetry? What potential problem arises if I do not use a narrow prototype?

+6
source share
2 answers

The NARROWPROTO macro NARROWPROTO 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 in turn is used in Xlib.h , for example, as follows:

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

KeyCode is a typedef of Xh

 typedef unsigned char KeyCode; 

so I think narrow here refers 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

+5
source

In addition to what was noted in INSTALL, it was also a FAQ, relevant for several years. Why does the scroll bar work? (also see notes in the change log during 2006 )

+1
source

Source: https://habr.com/ru/post/981516/


All Articles