-
Notifications
You must be signed in to change notification settings - Fork 180
Open
Description
I couldn't get the example shown in the docs to run properly (after fixing several syntax errors!), so I put together this simple test program:
#include "v7.h"
static v7_val_t
js_get_1024(struct v7* v7, v7_val_t this_obj, v7_val_t args)
{
(void)this_obj;
(void)args;
return v7_mk_number(v7, 1024);
}
int
main(void)
{
struct v7*
v7 = v7_create();
v7_set_method(v7, v7_get_global(v7), "get_1024", &js_get_1024);
v7_val_t
result = 0;
enum v7_err
status = v7_exec(v7, "print('get_1024: ' + get_1024())", &result);
if(status != V7_OK)
fprintf(stderr, "error: %d\n", (int)status);
else
printf("result: %f\n", (float)v7_get_double(v7, result));
v7_destroy(v7);
return (int)status;
}
The output of the program is:
get_1024: undefined
result: -nan
Program was compiled with GCC 6.2.1:
gcc -Wno-incompatible-pointer-types -lm -o test v7.c test.c
Any ideas as to what's going on?
Metadata
Metadata
Assignees
Labels
No labels