#include <julia.h>
int main(int argc, char* argv[]) {
jl_init();
jl_value_t* array_type_jl = nullptr;
jl_value_t* array_jl = nullptr;
jl_value_t* value_jl = nullptr;
JL_GC_PUSH3(&array_type_jl, &array_jl, &value_jl);
array_type_jl = jl_apply_array_type(
reinterpret_cast<jl_value_t*>(jl_float64_type), 1);
array_jl = reinterpret_cast<jl_value_t*>(jl_alloc_array_1d(array_type_jl, 0));
value_jl = jl_box_float64(64.0);
jl_array_ptr_1d_push(reinterpret_cast<jl_array_t*>(array_jl), value_jl);
jl_function_t* print_func = jl_get_function(jl_base_module, "println");
jl_call1(print_func, array_jl);
JL_GC_POP();
jl_atexit_hook(0);
}
For the code above, I was expecting array_jl
to contain a Float64
number 64.0
but it is actually 6.9438e-310
. What did I do wrong?