Search code examples
ceclipsevxworks

vxWorks warning: variable <task> is used before its value is set


This my problem warning (etoa:4549): variable "T1" is used before its value is set

enter image description here

When i run this the debugger turn on!

enter image description here

I don't know what the wrong and i can't run this!

CPU: Windows 6.1. Processor #0. Memory Size: 0x1f00000 (31Mb). BSP version 6.9/0. Created: Jul 17 2012, 10:12:44 ED&R Policy Mode: Deployed WDB Comm Type: WDB_COMM_PIPE WDB: Ready.

-> Exception !
Vector 13 : Access Violation
Program Counter:        0x00000000
Access Address (read):  0x00000000
Status Register:        0x00010246
Task: 0x1044e2d0 "T3"
0x1044e2d0 (T3): task 0x1044e2d0 has had a failure and has been stopped.
0x1044e2d0 (T3): fatal kernel task-level exception!
Exception !
Vector 13 : Access Violation
Program Counter:        0x00000000
Access Address (read):  0x00000000
Status Register:        0x00010246
Task: 0x1044dce0 "T1"
0x1044dce0 (T1): task 0x1044dce0 has had a failure and has been stopped.
0x1044dce0 (T1): fatal kernel task-level exception!
Exception !
Vector 13 : Access Violation
Program Counter:        0x00000000
Access Address (read):  0x00000000
Status Register:        0x00010246
Task: 0x1044dfd8 "T2"
0x1044dfd8 (T2): task 0x1044dfd8 has had a failure and has been stopped.
0x1044dfd8 (T2): fatal kernel task-level exception!

Solution

  • You have a variable int task_1 as well as a function with the same name void task_1(void). So, while you are intending to pass in the function pointer as an argument to taskSpawn, you are actually passing in the int variable task_1 instead. Which results in the warning that you are using task_1 before it has been assigned.

    You should change the names of one of these things, so that there is no conflict.

    int task_id_1, task_id_2, task_id_3, msgQueueId;
    
    task_id_1 = taskSpawn(..., (FUNCPTR)task_1, ...);