Hello. Question about macro resolving. (see thread...
# kotlin-native
r
Hello. Question about macro resolving. (see thread)
Header file
Copy code
//first "macro-tree"
#define GC_TYPE_INFO(p)	(p)->gc.u.type_info
#define GC_FLAGS(p)	zval_gc_flags(GC_TYPE_INFO(p))

//second "macro-tree"
#define GC_PROTECTED                (1<<5)
#define Z_COUNTED(zval)				(zval).value.counted
#define GC_IS_RECURSIVE(p) \
	(GC_FLAGS(p) & GC_PROTECTED)
#define Z_IS_RECURSIVE(zval)    GC_IS_RECURSIVE(Z_COUNTED(zval))
#define Z_IS_RECURSIVE_P(zv)   Z_IS_RECURSIVE(*(zv))
.def
-file
Copy code
static void print_gc_flags(zend_object *obj){
    printf("GC_FLAGS %u\n", GC_FLAGS(obj));
}

static void print_gc_flags2(zval *obj){
    printf("Z_IS_RECURSIVE_P %u\n", Z_IS_RECURSIVE_P(obj));
}
First function works perfectly. Second function throws error:
undefined symbol: Z_IS_RECURSIVE_P in Unknown on line 0
When I manually unwrap
Z_IS_RECURSIVE_P
into
GC_FLAGS((*(obj)).value.counted)
, then all is ok.
m
Z_IS_RECURSIVE_P(*obj)
Edit: sorry - missed that here
something_P(obj)
is just
something(*obj)
r
How it can affect to
undefined symbol
? But ok, I tried (and
&obj
just in case)
Copy code
static void print_gc_flags_zval(zval *obj){
    printf("%u\n", Z_IS_RECURSIVE_P(*obj));
}
Still
undefined symbol: Z_IS_RECURSIVE_P in Unknown on line 0
My fault. Wrong header file without this macro 🤦‍♂️
m
Well, but I personally not sure that Kotlin interop with something written almost entirely in C macroses is possible.
r
It works, but only with support of shaman dancing