@@ -20,17 +20,17 @@ miniexpr provides a simple, focused API with just two main functions:
2020
2121### ` me_compile() `
2222``` c
23- me_expr * me_compile (const char * expression, const me_variable * variables,
24- int var_count, me_dtype dtype, int * error);
23+ int me_compile (const char * expression, const me_variable * variables,
24+ int var_count, me_dtype dtype, int * error, me_expr ** out );
2525```
2626Compiles an expression for evaluation. Variable and output pointers are provided during evaluation rather than compilation.
2727
2828**Simple Usage**: Just provide variable names - everything else is optional:
2929
3030```c
3131me_variable vars[] = {{"x"}, {"y"}}; // Just the names!
32- me_expr *expr = me_compile("x + y", vars, 2, ME_FLOAT64, &err) ;
33-
32+ me_expr *expr = NULL ;
33+ if (me_compile("x + y", vars, 2, ME_FLOAT64, &err, &expr) != ME_COMPILE_SUCCESS) { /* handle error */ }
3434// Later, provide data in the same order as vars array
3535const void *data[] = {x_array, y_array}; // x first, y second
3636if (me_eval(expr, data, 2, output, nitems) != ME_EVAL_SUCCESS) { /* handle error */ }
@@ -39,7 +39,8 @@ if (me_eval(expr, data, 2, output, nitems) != ME_EVAL_SUCCESS) { /* handle error
3939For mixed types (use ` ME_AUTO ` for output dtype to infer from variables):
4040``` c
4141me_variable vars[] = {{"temp", ME_FLOAT64}, {"count", ME_INT32}};
42- me_expr * expr = me_compile("temp * count", vars, 2, ME_AUTO, &err);
42+ me_expr * expr = NULL;
43+ if (me_compile("temp * count", vars, 2, ME_AUTO, &err, &expr) != ME_COMPILE_SUCCESS) { /* handle error * / }
4344// Result type will be inferred (ME_FLOAT64 in this case)
4445```
4546
@@ -104,8 +105,8 @@ me_variable vars[] = {{"x"}, {"y"}};
104105int err;
105106
106107// Compile expression
107- me_expr *expr = me_compile("x + y", vars, 2, ME_FLOAT64, &err) ;
108-
108+ me_expr *expr = NULL ;
109+ if (me_compile("x + y", vars, 2, ME_FLOAT64, &err, &expr) != ME_COMPILE_SUCCESS) { /* handle error */ }
109110// Prepare data
110111double x_data[] = {1.0, 2.0, 3.0};
111112double y_data[] = {4.0, 5.0, 6.0};
0 commit comments