I am trying to create a scheduler, and when creating a thread, it gives the following error:
argument of type "DWORD (*)(LPVOID lpParameter)" is incompatible with parameter of type "LPTHREAD_START_ROUTINE".
I made the thread function static as suggested in other questions and it still gives the same error. Any solution or pointers would be appreciated.
This is the relevant part of my code:
#include "stdafx.h"
#include <string>
#include <windows.h>
#include <vector>
#include <stdio.h>
#include <thread>
using namespace std;
struct process {
int PID = 0;
int burstTime;
int arrivalTime;
int priority;
};
vector<process> allProcesses;
process myProcess;
vector<HANDLE> handles;
vector<DWORD> dwords;
static DWORD myThread(LPVOID lpParameter)
{
//execute my thread
}
void newArrival()
{
DWORD tempThreadID;
dwords.push_back(tempThreadID);
////error happens here at myThread
handles.push_back(CreateThread(0, 0, myThread, &allProcesses[0], 0, &dwords[dwords.size() - 1]));
//do even more stuff
}
void scheduler()
{
//do some other stuff
newArrival();
//do more stuff
}
int main()
{
//do some stuff
myProcess.arrivalTime = 1000;
myProcess.burstTime = 2500;
myProcess.priority = 90;
allProcesses = {myProcess};
thread scheduler(scheduler);
system("PAUSE > null");
return 0;
}