【发布时间】:2019-03-01 19:11:33
【问题描述】:
我有这个电话给czmq api:
int rc = zsock_connect(updates, ("inproc://" + uuidStr).c_str());
(Note: uuidStr is of type std::string and zsock_connect expects a const char* as its second argument)
这会导致编译器错误:
error: format not a string literal and no format arguments [-Werror=format-security]
int rc = zsock_connect(updates, ("inproc://" + uuidStr).c_str());
^
我试过了:
const char* connectTo = ("inproc://" + uuidStr).c_str();
int rc = zsock_connect(updates, connectTo);
还有
int rc = zsock_connect(updates, (const char*)("inproc://" +
uuidStr).c_str());
但错误仍然存在。
我该如何纠正这个问题?
上下文;我正在尝试使用 pip install 将此代码编译为 Linux 上的 Python 扩展。在 Windows 上,它使用 pip install 编译并运行得很好,大概是编译器更宽松。
【问题讨论】: