mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
translate-c: promote large integer macros to unsigned long long if necessary
Closes #10793 Co-authored-by: Veikka Tuominen <git@vexu.eu>
This commit is contained in:
parent
b45387f20e
commit
fdb8870852
@ -268,7 +268,7 @@ test "sizeof" {
|
||||
pub const CIntLiteralRadix = enum { decimal, octal, hexadecimal };
|
||||
|
||||
fn PromoteIntLiteralReturnType(comptime SuffixType: type, comptime number: comptime_int, comptime radix: CIntLiteralRadix) type {
|
||||
const signed_decimal = [_]type{ c_int, c_long, c_longlong };
|
||||
const signed_decimal = [_]type{ c_int, c_long, c_longlong, c_ulonglong };
|
||||
const signed_oct_hex = [_]type{ c_int, c_uint, c_long, c_ulong, c_longlong, c_ulonglong };
|
||||
const unsigned = [_]type{ c_uint, c_ulong, c_ulonglong };
|
||||
|
||||
|
||||
@ -48,3 +48,5 @@ typedef _Bool uintptr_t;
|
||||
|
||||
#define CAST_TO_BOOL(X) (_Bool)(X)
|
||||
#define CAST_TO_UINTPTR(X) (uintptr_t)(X)
|
||||
|
||||
#define LARGE_INT 18446744073709550592
|
||||
|
||||
@ -113,3 +113,7 @@ test "cast functions" {
|
||||
try expectEqual(true, h.CAST_TO_BOOL(S.foo));
|
||||
try expect(h.CAST_TO_UINTPTR(S.foo) != 0);
|
||||
}
|
||||
|
||||
test "large integer macro" {
|
||||
try expectEqual(@as(c_ulonglong, 18446744073709550592), h.LARGE_INT);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user