-
Notifications
You must be signed in to change notification settings - Fork 0
C and Cpp Integration
v2rayroot edited this page Jun 14, 2026
·
1 revision
Include the generated header from the same release ZIP as the binary.
char *status = GetStatus();
if (status != NULL) {
printf("%s\n", status);
FreeCString(status);
}char *validation = ValidateConfig(config_json, "{}");
if (validation != NULL) {
/* Parse JSON before releasing. */
FreeCString(validation);
}
char *error = Start(config_json, "{}");
if (error != NULL) {
fprintf(stderr, "%s\n", error);
FreeCString(error);
}#include <memory>
#include <string>
struct V2RootStringDeleter {
void operator()(char* value) const noexcept {
FreeCString(value);
}
};
using V2RootString = std::unique_ptr<char, V2RootStringDeleter>;
std::string status() {
V2RootString value(GetStatus());
return value ? value.get() : "";
}Never unload the library while the runtime or an FFI call is active.