Log in

View Full Version : Task FUNCPTR Issue


willson.thomas
11-03-2011, 19:01
I am having trouble defining a task. The code and compiler errors are below. If anyone knows what I'm doing wrong, help would be greatly appreciated!

Error:
C:/windriver/workspace/2011CompetitionCode/Arm.cpp:132: error: argument of type `int (LogomotionArm::)(LogomotionArm::ArmInitArgs*)' does not match `int (*)(...)'

Function Definition:
int InitialiseArm(ArmInitArgs *argsPTR)
{
while (argsPTR->armJagTask->GetForwardLimitOK())
{
argsPTR->armJagTask->Set(1);
Wait(0.01);
}
argsPTR->armJagTask->Set(0);
argsPTR->armPositionTask->Reset();
argsPTR->isInitialisingTask=false;
argsPTR->isInitialisedTask=true;
return (int)0;
}

Task Initialisation:
Task armInit("ArmInit",(FUNCPTR)(InitialiseArm));
armInit.Start((INT32)(&initArgs));

Thanks!

demosthenes2k8
11-03-2011, 19:42
Team 166's Framework166 (http://framework.googlecode.com) deals with this. We don't actually use the WPilib tasks, but we DO typecast our tasks into FUNCPTRs.

The main code we use is static int MainJacket(void *this_p, int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8);

Although I can't find the actual definition of FUNCPTR, from our code it's safe to assume that your task needs to take the same inputs as the MainJacket function snippet...or at least the same types. (There are almost certainly better names for the ints)

EDIT: This (http://www.chiefdelphi.com/forums/showthread.php?t=70542) old thread mentions that the task has to have int arguments...

EDIT2: I just found it:
typedef int (*FUNCPTR) (...); /* ptr to function returning int */
This basically means nothing that we don't already have by now, but it's a function that takes an int and, I believe, all int arguments.