0

I have following code to start a new thread

int number = 10;
_beginthread(ModbusReadWrite, 0, (void*)number);

The function is:

void ModbusReadWrite(void *arg)
{
    char inBuffer[BUF_SIZE];
    int PointNumber = &arg;
    ...
}

It shows an error:

error C2440: 'initializing' : cannot convert from 'void **' to 'int'

So, I need to define new parameter of type int and pass it to ModbusReadWrite() function. How can I achieve it?

nobody
  • 19,814
  • 17
  • 56
  • 77
user3048644
  • 93
  • 1
  • 5
  • 17

1 Answers1

2

The void* parameter may be used to pass anything. But it makes no sense to take its address:

int PointNumber = (int)arg;
ScottMcP-MVP
  • 10,337
  • 2
  • 15
  • 15