Take the 2-minute tour ×

I am using Mac, and i use homebrew to install zeromq. I want to use zeromq for my application. I tried to compile zmq.hpp https://github.com/zeromq/cppzmq/blob/master/zmq.hpp with

int main () {
    //  Prepare our context and socket
    zmq::context_t context (1);
    zmq::socket_t socket (context, ZMQ_REP);

    while (true) {
        zmq::message_t request;

        //  Wait for next request from client
        socket.recv (&request);

        //  Do some 'work'
        sleep (1);

        //  Send reply back to client
        zmq::message_t reply (5);
        socket.send (reply);
    return 0;

but it failed. The error shows

"frameworks/zmq/zmq.hpp:377:35: error: expected ';' at end of declaration list socket_t (const socket_t&) ZMQ_DELETED_FUNCTION; ^ ; frameworks/zmq/zmq.hpp:379:42: error: expected ';' at end of declaration list void operator = (const socket_t&) ZMQ_DELETED_FUNCTION;"

Why is this happened? The zmq.hpp code does not contain any errors. Please help.

Finally I do this and it worked.

#if __has_feature(cxx_deleted_functions)
        #define ZMQ_DELETED_FUNCTION = delete
        #define ZMQ_DELETED_FUNCTION

Thanks a lot. Audrey.

share|improve this question
I'm guessing it's doing = delete; and your compiler doesn't support it. –  chris Jan 30 '13 at 17:30
@chris is there a way to solve it? –  nan Jan 30 '13 at 17:31
What compiler are you using? –  AndreyT Jan 30 '13 at 17:35
add comment

1 Answer

up vote 5 down vote accepted

The macro ZMQ_DELETED_FUNCTION was apparently introduced to provide conditional support for such C++11 feature as "deleted functions" (= delete). Your compiler does not seem to support that C++11 feature. Hence the error.

By design, the zmq.hpp attempts to set this macro automatically, by analyzing the compiler version and defining the macro accordingly. It is possible that this automatic detection is being too optimistic. However, it is also possible that your compiler actually supports that feature, you just forgot to turn it on in the compiler settings.

BTW, I'm looking at the Clang section of the code that defines the macro

  #elif defined(__clang__)
    #if __has_feature(cxx_rvalue_references)
        #define ZMQ_HAS_RVALUE_REFS

    #if __has_feature(cxx_deleted_functions)
        #define ZMQ_DELETED_FUNCTION = delete

and it looks broken to me. If the compiler does not support cxx_deleted_functions feature, then macro ZMQ_DELETED_FUNCTION remains undefined (instead of being defined as empty). This is wrong.

Are you using Clang? If so, this could actually be the reason for your error. In that case the error can be fixed by pre-defining ZMQ_DELETED_FUNCTION as an empty macro, either as a global macro definition or in the source code before including zmq.hpp.

share|improve this answer
is there a way to resolve it, if I don't have the latest compiler? –  nan Jan 30 '13 at 17:34
@user1510529: What compiler are you using specifically? GCC? Clang? –  AndreyT Jan 30 '13 at 17:36
I am using gcc 4.2.1. ((GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)) –  nan Jan 30 '13 at 17:41
@user1510529: If you are using GCC, you should try specifying -std=c++11 or -std=c++0x or -std=gnu++11 or -std=gnu++0x in the command line, depending on your intent and on the version of GCC. –  AndreyT Jan 30 '13 at 17:44
You'll need somewhere near 4.7 for = delete;, though. –  chris Jan 30 '13 at 17:49
show 8 more comments

Your Answer


