Skip to content

Commit 9b5dd80

Browse files
committed
Stop including <uchar.h>, and instead map Rust char to uint32_t.
This is technically a breaking change for C++, unfortunately. Fixes #423.
1 parent 913b08d commit 9b5dd80

File tree

442 files changed

+23
-455
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

442 files changed

+23
-455
lines changed

src/bindgen/bindings.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ impl Bindings {
167167
out.new_line();
168168
out.write("#include <stdlib.h>");
169169
out.new_line();
170-
out.write("#include <uchar.h>");
171-
out.new_line();
172170
} else {
173171
out.write("#include <cstdarg>");
174172
out.new_line();

src/bindgen/ir/ty.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,15 @@ impl PrimitiveType {
132132
PrimitiveType::Char => "char",
133133
PrimitiveType::SChar => "signed char",
134134
PrimitiveType::UChar => "unsigned char",
135-
PrimitiveType::Char32 => "char32_t",
135+
// NOTE: It'd be nice to use a char32_t, but:
136+
//
137+
// * uchar.h is not present on mac (see #423).
138+
//
139+
// * char32_t isn't required to be compatible with Rust's char, as
140+
// the C++ spec only requires it to be the same size as
141+
// uint_least32_t, which is _not_ guaranteed to be 4-bytes.
142+
//
143+
PrimitiveType::Char32 => "uint32_t",
136144
PrimitiveType::Short => "short",
137145
PrimitiveType::Int => "int",
138146
PrimitiveType::Long => "long",

tests/expectations/alias.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include <stdbool.h>
33
#include <stdint.h>
44
#include <stdlib.h>
5-
#include <uchar.h>
65

76
enum Status {
87
Ok,

tests/expectations/alias.compat.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include <stdbool.h>
33
#include <stdint.h>
44
#include <stdlib.h>
5-
#include <uchar.h>
65

76
enum Status
87
#ifdef __cplusplus

tests/expectations/annotation.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include <stdbool.h>
33
#include <stdint.h>
44
#include <stdlib.h>
5-
#include <uchar.h>
65

76
enum C {
87
X = 2,

tests/expectations/annotation.compat.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include <stdbool.h>
33
#include <stdint.h>
44
#include <stdlib.h>
5-
#include <uchar.h>
65

76
enum C
87
#ifdef __cplusplus

tests/expectations/array.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include <stdbool.h>
33
#include <stdint.h>
44
#include <stdlib.h>
5-
#include <uchar.h>
65

76
typedef enum {
87
A,

tests/expectations/array.compat.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include <stdbool.h>
33
#include <stdint.h>
44
#include <stdlib.h>
5-
#include <uchar.h>
65

76
typedef enum {
87
A,

tests/expectations/asserted-cast.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <stdbool.h>
66
#include <stdint.h>
77
#include <stdlib.h>
8-
#include <uchar.h>
98

109
typedef struct I I;
1110

tests/expectations/asserted-cast.compat.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <stdbool.h>
66
#include <stdint.h>
77
#include <stdlib.h>
8-
#include <uchar.h>
98

109
typedef struct I I;
1110

0 commit comments

Comments
 (0)