zeromq / czmqpp

C++ wrapper for czmq. Aims to be minimal, simple and consistent.
Other
45 stars 27 forks source link

error: format not a string literal and no format arguments #42

Open chris-martin opened 8 years ago

chris-martin commented 8 years ago

I'm getting this error trying to build:

src/socket.cpp: In member function 'int czmqpp::socket::bind(const string&)':
src/socket.cpp:63:47: error: format not a string literal and no format arguments [-Werror=format-security]
     return zsocket_bind(self_, address.c_str());
                                               ^
src/socket.cpp: In member function 'int czmqpp::socket::connect(const string&)':
src/socket.cpp:68:50: error: format not a string literal and no format arguments [-Werror=format-security]
     return zsocket_connect(self_, address.c_str());
                                                  ^
cc1plus: some warnings being treated as errors
make: *** [Makefile:608: src/socket.lo] Error 1

Versions:

chris-martin commented 8 years ago

I'm not sure why the -Wno-format-security workaround from 30d12c0a5 isn't working, but I think the real fix is as simple as using a format string of %s, e.g.

return zsocket_connect(self_, "%s", address.c_str());

rather than

return zsocket_connect(self_, address.c_str());

(not sure though, I'm no C++ expert)