Suppose I have a Chapel string
var s : string;
How would I send it to a function that expects a char*
(since c_string
assumes const char *
)?
Here is an example that does this
extern {
#include <stdio.h>
static void f(char* argument) {
printf("%s\n", argument);
}
}
var s: string = "hello";
f(s.c_str():c_void_ptr:c_ptr(c_char));
Note the cast to c_void_ptr which is necessary before Chapel 1.19.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With