summaryrefslogtreecommitdiff
path: root/tests/headers/default-macro-constant-type.h
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2020-08-08 16:20:47 -0700
committerEmilio Cobos Álvarez <emilio@crisal.io>2020-08-09 13:01:46 +0200
commit53290e8f3535f118bcc06c048d34740233ef7821 (patch)
tree1e347f692a9ca8c3fe7cac7384273cea8dc7b98b /tests/headers/default-macro-constant-type.h
parent1127561bb232fe0aa3ef48cc8404b26ed3b7116c (diff)
Add --default-macro-constant-type
* --default-macro-constant-type could be 'signed' or 'unsigned' * Its default value is 'unsigned' to use u32/u64 for C macro constants that fit into the u32/u64 ranges. * For old C libraries that use macros as int/long parameter and/or return value types, their macros are better declared as i32/i64 if the values fit the i32/i64 ranges, to be compatible with c_int/c_long types. They can use "--default-macro-constant-type signed"
Diffstat (limited to 'tests/headers/default-macro-constant-type.h')
-rw-r--r--tests/headers/default-macro-constant-type.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/headers/default-macro-constant-type.h b/tests/headers/default-macro-constant-type.h
new file mode 100644
index 00000000..d11941b4
--- /dev/null
+++ b/tests/headers/default-macro-constant-type.h
@@ -0,0 +1,34 @@
+// Test default of --default-macro-constant-type
+// Negative values are i32 or i64; others are u32 or u64.
+
+#define N0 0
+#define N1 1ULL
+#define N2 2ULL
+
+#define N_1 (-1LL)
+#define N_2 (-2LL)
+
+#define MAX_U32 0xFFFFFFFFULL
+#define MAX_I32 (0x80000000ULL - 1)
+
+#define MAX_I32_Plus1 (MAX_I32 + 1)
+#define MAX_U32_Plus1 (MAX_U32 + 1)
+
+#define MAX_I32_Minus1 (MAX_I32 - 1)
+#define MAX_U32_Minus1 (MAX_U32 - 1)
+
+#define MIN_U32 0
+#define MIN_I32 (- (1ULL<<31))
+
+#define MIN_U32_Plus1 (MIN_U32 + 1)
+#define MIN_I32_Plus1 (MIN_I32 + 1)
+
+#define MIN_U32_Minus1 (MIN_U32 - 1)
+#define MIN_I32_Minus1 (MIN_I32 - 1)
+
+#define LONG12 123456789012ULL
+#define LONG_12 (- 123456789012ULL)
+
+// Function parameter and return types are not affected.
+int foo(int, signed, unsigned, char, unsigned char, signed char);
+long bar(long, long long);