-1

I happened to come across a macro definition as shown below in a c++ code(https://github.com/LairdCP/UwTerminalX).

 #define SpeedModeInactive                 0b00
 #define SpeedModeRecv                     0b01
 #define SpeedModeSend                     0b10
 #define SpeedModeSendRecv                 0b11

When I tried to compile it using visual studio 2010, it giving me the following error.

Error   14  error C2059: syntax error : ')' 

What is the meaning of this macro? The usage of macro is shown below.

if ((gchSpeedTestMode == SpeedModeSendRecv || gchSpeedTestMode == SpeedModeRecv) && (gintSpeedBytesReceived10s > 0 || ui->edit_SpeedBytesRec10s->text().toInt() > 0))
{
    //Data has been received in the past 10 seconds: start a timer before stopping to catch the extra data packets
    gchSpeedTestMode = SpeedModeRecv;
    gtmrSpeedTestDelayTimer = new QTimer();
    gtmrSpeedTestDelayTimer->setSingleShot(true);
    connect(gtmrSpeedTestDelayTimer, SIGNAL(timeout()), this, SLOT(SpeedTestStopTimer()));
    gtmrSpeedTestDelayTimer->start(5000);

    //Show message that test will end soon
    ui->statusBar->showMessage("Waiting 5 seconds for packets to be received... Click cancel again to stop instantly.");
}
kernel
  • 326
  • 1
  • 3
  • 18

1 Answers1

5

It is because visual studio doesn't recognize binary values (starting with 0bXXX) but, you can simply define as a hex values just like that:

#define SpeedModeInactive                 0x0
#define SpeedModeRecv                    0x1
#define SpeedModeSend                    0x2
#define SpeedModeSendRecv                0x3

The use of binary literals was first introduced in C++14 which is not supported by VS2010, https://en.wikipedia.org/wiki/C%2B%2B14#Binary_literals

MikNiller
  • 1,242
  • 11
  • 17