2
我需要從C++傳遞字符串值到C庫。 你怎麼稱CppCallToC
或.cpp我怎樣才能訪問struct rtmp_stream *stream;
?從C++如何執行一個方法或訪問C中的struct?
C++文件:UI /窗口鹼性-main.cpp中:
void OBSBasic::Load(const char *file) {
//From C++ how to go to the C method?
CppCallToC();
}
C文件:插件/ OBS-輸出/ RTMP-stream.c:
static void CppCallToC() {
//https://github.com/jp9000/obs-studio/blob/master/libobs/util/dstr.h
//struct dstr path, key;
struct rtmp_stream *stream;
//dstr_printf(&stream->path, obs_path);
//dstr_printf(&stream->key, obs_key);
}
'std :: string'和引用不是'c'。 – Alex
1.您不能在不同的功能中訪問局部變量; 2.無論如何你都不能調用這個函數 - 而且你不應該 - 因爲它是靜態的;這看起來像[XY問題](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem)。 – molbdnilo