dingmaotu / mql-zmq

ZMQ binding for the MQL language (both 32bit MT4 and 64bit MT5)
Apache License 2.0
553 stars 301 forks source link

SocketOptions.mqh doesn't compile in latest version of MT5 #63

Closed gorgeousprince closed 1 year ago

gorgeousprince commented 1 year ago

In Include\Zmq\SocketOptions.mqh file lines 25-45

#import "libzmq.dll"
// We can overload the same function for different data types
// as in the C level the optval paramter is just a pointer
#define SOCKOPT_OVERLOAD_ARRAY(TYPE) \
int zmq_setsockopt(intptr_t s,int option,const TYPE &optval[],\
                   size_t optvallen);\
int zmq_getsockopt(intptr_t s,int option,TYPE &optval[],\
                   size_t &optvallen);\

#define SOCKOPT_OVERLOAD(TYPE) \
int zmq_setsockopt(intptr_t s,int option,const TYPE &optval,\
                   size_t optvallen);\
int zmq_getsockopt(intptr_t s,int option,TYPE &optval,\
                   size_t &optvallen);\

SOCKOPT_OVERLOAD_ARRAY(uchar)
SOCKOPT_OVERLOAD(long)
SOCKOPT_OVERLOAD(ulong)
SOCKOPT_OVERLOAD(int)
SOCKOPT_OVERLOAD(uint)
#import

It seems like the issue might be related to the backslashes at the end of each line in the #define statements. Backslashes at the end of a line in a macro definition are used to indicate that the macro continues on the next line. However, in this case, it appears that they are causing problems during compilation. I tried remove the backslashes at the end of each line in the #define statements and it compiles again.

#import "libzmq.dll"
// We can overload the same function for different data types
// as in the C level the optval paramter is just a pointer
#define SOCKOPT_OVERLOAD_ARRAY(TYPE) \
int zmq_setsockopt(intptr_t s,int option,const TYPE &optval[],\
                   size_t optvallen);\
int zmq_getsockopt(intptr_t s,int option,TYPE &optval[],\
                   size_t &optvallen);

#define SOCKOPT_OVERLOAD(TYPE) \
int zmq_setsockopt(intptr_t s,int option,const TYPE &optval,\
                   size_t optvallen);\
int zmq_getsockopt(intptr_t s,int option,TYPE &optval,\
                   size_t &optvallen);

SOCKOPT_OVERLOAD_ARRAY(uchar)
SOCKOPT_OVERLOAD(long)
SOCKOPT_OVERLOAD(ulong)
SOCKOPT_OVERLOAD(int)
SOCKOPT_OVERLOAD(uint)
#import

Please modify the code accordingly and make a new push and commit.

dingmaotu commented 1 year ago

Thanks for reporting problems. But I tried this on latest MT4 (build 2404, 7 Jul 2023) and MT5 (build 3914, 4 Sep 2023) and they both compiled fine. So I figured this is not a bug. If you still have problems, please provide your metaeditor version and error messages and I'll look into it futher.