tyrquake
tyrquake copied to clipboard
Allow compile with -std=c23
- Fixes #134
When compiling with -std=c23 the following errors are observed.
common/qtypes.h:37:15: error: cannot use keyword 'false' as enumeration constant
37 | typedef enum{ false, true, ENSURE_INT_QBOOL = 0x70000000 } qboolean;
| ^~~~~
common/qtypes.h:37:23: error: cannot use keyword 'true' as enumeration constant
37 | typedef enum{ false, true, ENSURE_INT_QBOOL = 0x70000000 } qboolean;
| ^~~~
common/net_main.c:869:9: error: too many arguments to function 'pp->procedure'; expected 0, have 1
869 | pp->procedure(pp->arg);
| ^~ ~~~~~~~
common/net.h:320:12: note: declared here
320 | void (*procedure) ();
| ^~~~~~~~~
common/net_main.c:112:56: error: initialization of 'void (*)(void *)' from incompatible pointer type 'void (*)(void)' [-Wincompatible-pointer-types]
112 | static PollProcedure slistSendProcedure = { NULL, 0.0, Slist_Send };
| ^~~~~~~~~~
common/net_main.c:113:56: error: initialization of 'void (*)(void *)' from incompatible pointer type 'void (*)(void)' [-Wincompatible-pointer-types]
113 | static PollProcedure slistPollProcedure = { NULL, 0.0, Slist_Poll };
| ^~~~~~~~~~
common/net_dgrm.c:512:8: error: initialization of 'void (*)(void *)' from incompatible pointer type 'void (*)(struct test_poll_state *)' [-Wincompatible-pointer-types]
512 | Test_Poll,
| ^~~~~~~~~
common/net_dgrm.c:647:7: error: initialization of 'void (*)(void *)' from incompatible pointer type 'void (*)(struct test_poll_state *)' [-Wincompatible-pointer-types]
647 | Test2_Poll,
| ^~~~~~~~~~
Fix:
- update enum as false0 and true1 as the enum are already 0 and 1, and map to false/true
- Update the function declarations to pass (void *) as procedure
@LibretroAdmin if you could please review and if ok merge.
Sorry for noticing this so late
Sorry for noticing this so late
All good - thanks for merging.
For the false0/true1 - update enum as false0 and true1 as the enum are already 0 and 1, and map to false/true These should already resolve to 0 and 1 respectively. But c23 doesn’t allow us to use false in enumeration.
https://github.com/libretro/tyrquake/commit/1a0e60c8f52bcb4d1440b64fef3ccf846f9c94f0#commitcomment-158089382
It seems the C++23 fix here was partially reverted. Can it be re-applied?
Specifically I mean this:
From bb2912597a37d52e99891510d8c43352127457dd Mon Sep 17 00:00:00 2001
From: Rudi Heitbaum <[email protected]>
Date: Wed, 15 Jan 2025 02:16:29 +0000
Subject: [PATCH] Allow compile with -std=c23
When compiling with -std=c23 the following errors are observed.
common/qtypes.h:37:15: error: cannot use keyword 'false' as enumeration constant
37 | typedef enum{ false, true, ENSURE_INT_QBOOL = 0x70000000 } qboolean;
| ^~~~~
common/qtypes.h:37:23: error: cannot use keyword 'true' as enumeration constant
37 | typedef enum{ false, true, ENSURE_INT_QBOOL = 0x70000000 } qboolean;
| ^~~~
Fix:
- update enum as false0 and true1 as the enum are already 0 and 1, and map to false/true
---
common/qtypes.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/qtypes.h b/common/qtypes.h
index 97633fc..3ea14a0 100644
--- a/common/qtypes.h
+++ b/common/qtypes.h
@@ -33,7 +33,7 @@ typedef unsigned char byte;
typedef enum{ false, true };
typedef int qboolean;
#else
-typedef enum{ false, true, ENSURE_INT_QBOOL = 0x70000000 } qboolean;
+typedef enum{ false0, true1, ENSURE_INT_QBOOL = 0x70000000 } qboolean;
#endif
#ifndef offsetof
--
2.51.0
Specifically I mean this:
From bb2912597a37d52e99891510d8c43352127457dd Mon Sep 17 00:00:00 2001 From: Rudi Heitbaum <[email protected]> Date: Wed, 15 Jan 2025 02:16:29 +0000 Subject: [PATCH] Allow compile with -std=c23 When compiling with -std=c23 the following errors are observed. common/qtypes.h:37:15: error: cannot use keyword 'false' as enumeration constant 37 | typedef enum{ false, true, ENSURE_INT_QBOOL = 0x70000000 } qboolean; | ^~~~~ common/qtypes.h:37:23: error: cannot use keyword 'true' as enumeration constant 37 | typedef enum{ false, true, ENSURE_INT_QBOOL = 0x70000000 } qboolean; | ^~~~ Fix: - update enum as false0 and true1 as the enum are already 0 and 1, and map to false/true --- common/qtypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/qtypes.h b/common/qtypes.h index 97633fc..3ea14a0 100644 --- a/common/qtypes.h +++ b/common/qtypes.h @@ -33,7 +33,7 @@ typedef unsigned char byte; typedef enum{ false, true }; typedef int qboolean; #else -typedef enum{ false, true, ENSURE_INT_QBOOL = 0x70000000 } qboolean; +typedef enum{ false0, true1, ENSURE_INT_QBOOL = 0x70000000 } qboolean; #endif #ifndef offsetof -- 2.51.0
I didn’t bump in LE because the compile fails with the 1a0e60c8f52bcb4d1440b64fef3ccf846f9c94f0 revert https://github.com/LibreELEC/LibreELEC.tv/blob/master/packages/emulation/libretro-tyrquake/package.mk