c23 boolean conflict
when compiling libXt-1.3.0 with -std=gnu2x I get:
CC TMparse.lo
Shell.c: In function '_XtShellAncestorSensitive':
Shell.c:1005:20: error: expected identifier or '(' before 'true'
1005 | static Boolean true = True;
| ^~~~
Shell.c:1008:35: error: lvalue required as unary '&' operand
1008 | value->addr = (XPointer) (&true);
| ^
make[3]: *** [Makefile:651: Shell.lo] Error 1
make[3]: *** Waiting for unfinished jobs....
CC TMprint.lo
compiling without -std=gnu2x doesn't have this problem
This is because, as of C23, there is a new boolean type, and this redefinition of the now reserved word 'true' conflicts with the builtin/reserved word 'true' from c23
options
- use a different word for true (this would work for both c23 and previous versions of c)
- ifdef guard this in the case of c23
Best option honestly is just 1, because it's just a local variable, used only once.
Here's an example of what I mean, which allows for compilation using c23
--- libXt-1.3.0/src/Shell.c 2023-04-09 14:48:48.000000000 -0600
+++ fixed/src/Shell.c 2023-11-12 01:21:05.921215946 -0600
@@ -1002,10 +1002,9 @@
static void
_XtShellAncestorSensitive(Widget widget, int closure, XrmValue *value)
{
- static Boolean true = True;
-
+ static Boolean t = True;
if (widget->core.parent == NULL)
- value->addr = (XPointer) (&true);
+ value->addr = (XPointer) (&t);
else
_XtCopyFromParent(widget, closure, value);
}
Edited by jeff cliff