Skip to content

Commit 598b332

Browse files
authored
Drop bool typedef (#71)
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. Signed-off-by: Guido Günther <agx@sigxcpu.org>
1 parent b0183b1 commit 598b332

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

c-shared-util.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
#endif
1515

1616
#ifndef __cplusplus
17-
typedef int bool;
17+
#if __GNUC__ < 15
1818
#define false 0
1919
#define true 1
2020
#endif
21+
#endif
2122

22-
#endif /* __UTIL_H__ */
23+
#endif /* __UTIL_H__ */

c-shared-varray.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ varray_length(varray *array)
5252
return array->index + 1;
5353
}
5454

55-
bool
55+
int
5656
varray_is_empty (varray *array)
5757
{
5858
return (varray_length (array) == 0);
@@ -113,8 +113,8 @@ varray_insert(varray *array, int index, void *data)
113113
array->memory[index] = data;
114114
}
115115

116-
bool
117-
varray_exists (varray *array, void *item, bool (*equals)(void *left, void *right))
116+
int
117+
varray_exists (varray *array, void *item, int (*equals)(void *left, void *right))
118118
{
119119
int i;
120120

c-shared-varray.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ varray_push(varray *array, void *data);
2424
VARNAM_EXPORT extern int
2525
varray_length(varray *array);
2626

27-
VARNAM_EXPORT extern bool
27+
VARNAM_EXPORT extern int
2828
varray_is_empty (varray *array);
2929

30-
VARNAM_EXPORT extern bool
31-
varray_exists (varray *array, void *item, bool (*equals)(void *left, void *right));
30+
VARNAM_EXPORT extern int
31+
varray_exists (varray *array, void *item, int (*equals)(void *left, void *right));
3232

3333
VARNAM_EXPORT extern void
3434
varray_clear(varray *array);
@@ -42,4 +42,4 @@ varray_insert(varray *array, int index, void *data);
4242
VARNAM_EXPORT extern void
4343
varray_free(varray *array, void (*destructor)(void*));
4444

45-
#endif /* VARRAY_H */
45+
#endif /* VARRAY_H */

c-shared.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void destroyTransliterationResult(TransliterationResult* result)
5858
result = NULL;
5959
}
6060

61-
SchemeDetails* makeSchemeDetails(char* Identifier, char* LangCode, char* DisplayName, char* Author, char* CompiledDate, bool IsStable)
61+
SchemeDetails* makeSchemeDetails(char* Identifier, char* LangCode, char* DisplayName, char* Author, char* CompiledDate, int IsStable)
6262
{
6363
SchemeDetails* sd = (SchemeDetails*) malloc (sizeof(SchemeDetails));
6464
sd->Identifier = Identifier;

c-shared.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ typedef struct SchemeDetails_t {
4646
char* DisplayName;
4747
char* Author;
4848
char* CompiledDate;
49-
bool IsStable;
49+
int IsStable;
5050
} SchemeDetails;
5151

52-
SchemeDetails* makeSchemeDetails(char* Identifier, char* LangCode, char* DisplayName, char* Author, char* CompiledDate, bool IsStable);
52+
SchemeDetails* makeSchemeDetails(char* Identifier, char* LangCode, char* DisplayName, char* Author, char* CompiledDate, int IsStable);
5353

5454
void destroySchemeDetailsArray(void* cSchemeDetails);
5555

@@ -79,4 +79,4 @@ Symbol* makeSymbol(int Identifier, int Type, int MatchType, char* Pattern, char*
7979

8080
void destroySymbolArray(void* cSymbols);
8181

82-
#endif /* __C_SHARED_H__ */
82+
#endif /* __C_SHARED_H__ */

0 commit comments

Comments
 (0)