Dsafds Dsafds - 3 months ago 13
C++ Question

expected primary-expression before ',' token

Im currently getting the error:

kernel.c++:76:21: error: expected primary-expression before ',' token
Task task1(&gdt , taskA);
^
kernel.c++:77:21: error: expected primary-expression before ',' token
Task task2(&gdt , taskB);


Not sure why this is happening here is the code of my kernel.c++ simplified:

void taskA();
void taskB();

extern "C" void kernelMain
(
/*arguments...*/
)


{
gdt gt;

TaskManager taskManager;
Task task1(&gdt , taskA);
Task task2(&gdt , taskB);
taskManager.AddTask(&task1);
taskManager.AddTask(&task2);
}

void taskA()
{
while(true)
printf("A");
}


void taskB()
{
while(true)
printf("B");
}


If you want to see my actual kernel code : https://github.com/amanuel2/OS_Mirror/blob/master/kernel.c%2B%2B .. Any Help

Here is my task.h simplified:

class Task
{
friend class TaskManager;
private:
uint8_t stack[4096]; // 4 KiB
CPUState* cpustate;
public:


Task(gdt *GlobalDescriptorTable, void entrypoint());
~Task();
};


class TaskManager
{
private:
Task* tasks[256];
uint32_t num_task;
uint32_t current_task;
public:
TaskManager();
~TaskManager();
bool AddTask(Task* task);
CPUState* Schedule(CPUState* cpustate);
};


If you want to see whole code for task.h here it is : https://github.com/amanuel2/OS_Mirror/blob/master/task.h ..

and finally minimized task.c++:

Task::Task(gdt *GlobalDescriptorTable, void entrypoint())
{
/*Stuff Happenes Here.. But i Minimized it*/
}


If you want to see the actual task.c++ here it is : https://github.com/amanuel2/OS_Mirror/blob/master/task.c%2B%2B .. I dont understand why i get that error. Any Help Would be greatly appreciated thankyou.

Answer

Your error is probably in these two lines:

Task task1(&gdt , taskA);
Task task2(&gdt , taskB);

It should be

Task task1(&gt , taskA);
Task task2(&gt , taskB);

You should change your type names and variable names so they don't look alike that much so as to avoid these kind of errors.