From: PatR Date: Sun, 10 Mar 2019 23:06:29 +0000 (-0700) Subject: win/curses comment X-Git-Tag: NetHack-3.6.2_Released~43^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=53777fa03a1c5865d1f7b706fe98a1c4b30fa54e;p=nethack win/curses comment Twice I've gone through the curses code to deal with CHAR_P, BOOLEAN_P, and so forth. Both times I eventually changed my mind. This time I'm just adding an explanatory comment instead. --- diff --git a/win/curses/cursdial.c b/win/curses/cursdial.c index c8ee59808..966f15109 100644 --- a/win/curses/cursdial.c +++ b/win/curses/cursdial.c @@ -17,6 +17,36 @@ #define strncasecmp strncmpi #endif +/* + * Note: + * + * Prototypes need to use the widened/unwidened type macros (CHAR_P, &c) + * in order to match fields of the window_procs struct (see winprocs.h). + * But for a standard-conforming compiler, we'll end up with the widened + * types necessary to match the mixed prototype/old-style function + * definition environment as used by nethack's core. Prototype +int func(CHAR_P); + * becomes +int func(int); + * after expansion, which matches the definition +int func(arg) char arg; { ... } + * according to the rules of the C standard. But the use of new-style + * definitions +int func(char arg) { ... } + * by the curses interface turns that into a conflict. No widening takes + * place so it ought to be 'int func(char);' instead. Unfortunately that + * would be incompatible for functions assigned to window_procs. + * + * So, the code here (also cursmain.c and cursinvt.c) is mis-using the + * widening macros for variable types +int func(CHAR_P arg) { ... } + * (no doubt modelling it after the C++ code in win/Qt where the option + * to switch the applicable definitions to old-style isn't available). + * Other alternatives aren't significantly better so just live with it. + * [Redoing the windowing interface to avoid narrow arguments would be + * better since that would fix Qt's usage too.] + */ + /* Dialog windows for curses interface */