From: =?utf-8?q?Guido_G=C3=BCnther?= <agx@sigxcpu.org>
Date: Sat, 6 Sep 2025 09:21:56 +0200
Subject: Drop `bool` typedef
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

GCC throws an error when a bool type is defined:

```
./c-shared-util.h:17:15: error: 'bool' cannot be defined via 'typedef'
   17 |   typedef int bool;
      |               ^~~~
./c-shared-util.h:17:15: note: 'bool' is a keyword with '-std=c23' onwards
```

Since bool and int don't need to be the same types at the ABI boundary
we must replace `bool` by `int` there. We can still use `true` and
`false` internally due to implicit type conversion.

Forwarded: https://github.com/varnamproject/govarnam/pull/71
Signed-off-by: Guido Günther <agx@sigxcpu.org>
---
 c-shared-util.h   | 5 +++--
 c-shared-varray.c | 6 +++---
 c-shared-varray.h | 8 ++++----
 c-shared.c        | 2 +-
 c-shared.h        | 6 +++---
 5 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/c-shared-util.h b/c-shared-util.h
index e08c3ba..d00df69 100644
--- a/c-shared-util.h
+++ b/c-shared-util.h
@@ -14,9 +14,10 @@
 #endif
 
 #ifndef __cplusplus
-  typedef int bool;
+#if __GNUC__ < 15
   #define false 0
   #define true  1
 #endif
+#endif
 
-#endif /* __UTIL_H__ */
\ No newline at end of file
+#endif /* __UTIL_H__ */
diff --git a/c-shared-varray.c b/c-shared-varray.c
index 3016039..34c67c9 100644
--- a/c-shared-varray.c
+++ b/c-shared-varray.c
@@ -52,7 +52,7 @@ varray_length(varray *array)
     return array->index + 1;
 }
 
-bool
+int
 varray_is_empty (varray *array)
 {
     return (varray_length (array) == 0);
@@ -113,8 +113,8 @@ varray_insert(varray *array, int index, void *data)
     array->memory[index] = data;
 }
 
-bool
-varray_exists (varray *array, void *item, bool (*equals)(void *left, void *right))
+int
+varray_exists (varray *array, void *item, int (*equals)(void *left, void *right))
 {
     int i;
 
diff --git a/c-shared-varray.h b/c-shared-varray.h
index a26879b..0f6a1df 100644
--- a/c-shared-varray.h
+++ b/c-shared-varray.h
@@ -24,11 +24,11 @@ varray_push(varray *array, void *data);
 VARNAM_EXPORT extern int
 varray_length(varray *array);
 
-VARNAM_EXPORT extern bool
+VARNAM_EXPORT extern int
 varray_is_empty (varray *array);
 
-VARNAM_EXPORT extern bool
-varray_exists (varray *array, void *item, bool (*equals)(void *left, void *right));
+VARNAM_EXPORT extern int
+varray_exists (varray *array, void *item, int (*equals)(void *left, void *right));
 
 VARNAM_EXPORT extern void
 varray_clear(varray *array);
@@ -42,4 +42,4 @@ varray_insert(varray *array, int index, void *data);
 VARNAM_EXPORT extern void
 varray_free(varray *array, void (*destructor)(void*));
 
-#endif /* VARRAY_H */
\ No newline at end of file
+#endif /* VARRAY_H */
diff --git a/c-shared.c b/c-shared.c
index 607f06b..e9c7070 100644
--- a/c-shared.c
+++ b/c-shared.c
@@ -58,7 +58,7 @@ void destroyTransliterationResult(TransliterationResult* result)
   result = NULL;
 }
 
-SchemeDetails* makeSchemeDetails(char* Identifier, char* LangCode, char* DisplayName, char* Author, char* CompiledDate, bool IsStable)
+SchemeDetails* makeSchemeDetails(char* Identifier, char* LangCode, char* DisplayName, char* Author, char* CompiledDate, int IsStable)
 {
   SchemeDetails* sd = (SchemeDetails*) malloc (sizeof(SchemeDetails));
   sd->Identifier = Identifier;
diff --git a/c-shared.h b/c-shared.h
index f32bf4d..1e38996 100644
--- a/c-shared.h
+++ b/c-shared.h
@@ -46,10 +46,10 @@ typedef struct SchemeDetails_t {
   char* DisplayName;
   char* Author;
   char* CompiledDate;
-  bool IsStable;
+  int   IsStable;
 } SchemeDetails;
 
-SchemeDetails* makeSchemeDetails(char* Identifier, char* LangCode, char* DisplayName, char* Author, char* CompiledDate, bool IsStable);
+SchemeDetails* makeSchemeDetails(char* Identifier, char* LangCode, char* DisplayName, char* Author, char* CompiledDate, int IsStable);
 
 void destroySchemeDetailsArray(void* cSchemeDetails);
 
@@ -79,4 +79,4 @@ Symbol* makeSymbol(int Identifier, int Type, int MatchType, char* Pattern, char*
 
 void destroySymbolArray(void* cSymbols);
 
-#endif /* __C_SHARED_H__ */
\ No newline at end of file
+#endif /* __C_SHARED_H__ */
