@@ -67,9 +67,10 @@ static ffi_fptr resolve_fn (std::string symbol_name)
6767AST::AstNode *AST::dpi_call (const std::string &rtype, const std::string &fname, const std::vector<std::string> &argtypes, const std::vector<AstNode*> &args)
6868{
6969 AST::AstNode *newNode = nullptr ;
70- union { double f64 ; float f32 ; int32_t i32 ; void *ptr; } value_store [args.size () + 1 ];
71- ffi_type *types [args.size () + 1 ];
72- void *values [args.size () + 1 ];
70+ union value { double f64 ; float f32 ; int32_t i32 ; void *ptr; };
71+ std::vector<value> value_store (args.size () + 1 );
72+ std::vector<ffi_type *> types (args.size () + 1 );
73+ std::vector<void *> values (args.size () + 1 );
7374 ffi_cif cif;
7475 int status;
7576
@@ -118,10 +119,10 @@ AST::AstNode *AST::dpi_call(const std::string &rtype, const std::string &fname,
118119 log_error (" invalid rtype '%s'.\n " , rtype.c_str ());
119120 }
120121
121- if ((status = ffi_prep_cif (&cif, FFI_DEFAULT_ABI, args.size (), types[args.size ()], types)) != FFI_OK)
122+ if ((status = ffi_prep_cif (&cif, FFI_DEFAULT_ABI, args.size (), types[args.size ()], types. data () )) != FFI_OK)
122123 log_error (" ffi_prep_cif failed: status %d.\n " , status);
123124
124- ffi_call (&cif, resolve_fn (fname.c_str ()), values[args.size ()], values);
125+ ffi_call (&cif, resolve_fn (fname.c_str ()), values[args.size ()], values. data () );
125126
126127 if (rtype == " real" ) {
127128 newNode = new AstNode (AST_REALVALUE);
0 commit comments