(MOD) Defined 1 more macro "cast".
This commit is contained in:
3
common.h
3
common.h
@@ -61,6 +61,9 @@
|
||||
/* Allows different macros using "_" nested with each other. */
|
||||
# define nest(v1, v2, b) { clone(v1, v2) b }
|
||||
|
||||
/* Cast Var "var" into builtin type in C specified with "type". */
|
||||
# define cast(var, type) (*(type *)var.addr)
|
||||
|
||||
// # define lambda(param, body, capfmt, ...) {\
|
||||
// /* Duplicate everything from cap. */\
|
||||
// va_list ptr;\
|
||||
|
3
test.c
3
test.c
@@ -53,7 +53,8 @@ Status Main(void)
|
||||
fail(Array_Create(&arr, 8, sizeof(long long)));
|
||||
|
||||
for (register int i = 0; i < arr.len; i++) {
|
||||
(void)printf("%d:\t%p\n", i, arr.members[i].addr);
|
||||
cast(arr.members[i], long long) = INT64_MAX;
|
||||
(void)printf("%lld\n", cast(arr.members[i], long long));
|
||||
}
|
||||
|
||||
Array_Delete(&arr);
|
||||
|
Reference in New Issue
Block a user