Compilation Error

I am getting the below given errors for the following program though all the variables have been declared and used appropriately. Please Help. The environment is AIX.
Error:
------
"gbsizeprofile.c", line 67.4: 1506-275 (S) Unexpected text 'void' encountered.
"gbsizeprofile.c", line 67.10: 1506-045 (S) Undeclared identifier Iid.
"gbsizeprofile.c", line 68.4: 1506-275 (S) Unexpected text 'void' encountered.
"gbsizeprofile.c", line 68.10: 1506-045 (S) Undeclared identifier Sid.
"gbsizeprofile.c", line 69.4: 1506-275 (S) Unexpected text 'void' encountered.
"gbsizeprofile.c", line 69.10: 1506-045 (S) Undeclared identifier Spid.
"gbsizeprofile.c", line 70.19: 1506-276 (S) Syntax error: possible missing ':'?
"gbsizeprofile.c", line 80.26: 1506-045 (S) Undeclared identifier attr.
"gbsizeprofile.c", line 132.44: 1506-280 (W) Function argument assignment between types "void*(*)(void*)" and "void*(*)(void*,void*,void*)" is not allowed.
[05-28-09 11:17:08] ==>dcc: Finished RC=1 make: The error code from the last command is 1.
Stop. [05-28-09 11:17:08] ==>dmake: Finished, RC=2

DESC:
------
void *InvExtract(void *t)
{
<CURRENTLY PRINTS THE THREAD ID AND EXITS>
<NEED TO EXECUTE SOME SQLS>
}
void *SalesExtract(void *t)
{
<CURRENTLY PRINTS THE THREAD ID AND EXITS>
<NEED TO EXECUTE SOME SQLS>
}

void *ShipExtract(void *t)
{
<CURRENTLY PRINTS THE THREAD ID AND EXITS>
<NEED TO EXECUTE SOME SQLS>
}
void *ExtractData(void *t,void *t1,void *t2)
{
<CREATES 3 THREADS AND JOINS THEM>
<THE 3 THREADS POINT TO THE 3 FUNCTIONS DEFINED ABOVE>
}

int main ()
{
<CREATES MAIN THREADS AND CALLS ExtractData FUNCTION>
<CURRENTLY JUST DISPLAYS SOME MESSAGE>
<AFTER SUCCESSFUL RETURN FROM THE MAIN THREAD NEED TO EXEC SOME SQLS>
}

Program:
---------

/****************************************************************************************************
*

  •   				UK SIZE PROFILING WEEKLY BATCH JOB
    

*

  • DATE CREATED: 19 MAY 2009
    ****************************************************************************************************/

#include<stdio.h>
#include<stdlib.h>
#include "pthread.h"
#define NUM_THREADS 3

/****************************************************************************************************

  •   						FUNCTION DEFINITION
    
  • The InvExtract extracs the inventory of all items for the current week in Apparel Departments.
  • The SalesExtract extracs the sales of all items for the current week in Apparel Departments.
  • The ShipExtract extracs the ship of all items for the current week in Apparel Departments.
  • The job will be run parallely using threads
    *
    ****************************************************************************************************/
    void *InvExtract(void t)
    {
    int i;
    long tid;
    tid = (long)t;
    printf("Thread %ld starting... Thread Id\n",tid);
    /
    EXEC SQL UK_INV_EXTRACT.btq; /
    printf("Thread %ld done. Inventory Extract Complete \n",tid);
    pthread_exit((void
    ) t);
    return 0;
    }

void *SalesExtract(void t)
{
int i;
long tid;
tid = (long)t;
printf("Thread %ld starting... Thread Id\n",tid);
/
EXEC SQL UK_SALES_EXTRACT.btq; /
printf("Thread %ld done. Sales Extract Complete \n",tid);
pthread_exit((void
) t);
return 0;
}

void *ShipExtract(void t)
{
int i;
long tid;
tid = (long)t;
printf("Thread %ld starting... Thread Id\n",tid);
/
EXEC SQL UK_SHIP_EXTRACT.btq; /
printf("Thread %ld done.Shiment Extract Complete \n",tid);
pthread_exit((void
) t);
return 0;
}

void *ExtractData(void *t,void *t1,void t2)
{
pthread_t TInv,TSales,TShip;
int i;
int rc = 0;
long tid,tid1,tid2;
double result=0.0;
tid = (long)t;
tid1 = (long)t+1;
tid2 = (long)t+2;
void Iid;
void Sid;
void Spid;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
printf("Thread %ld starting...\n",tid);
rc = pthread_create(&TInv, &attr, InvExtract, (void
)&t) ;
if(rc)
{
printf("ERROR; return code from InvExtract pthread_create() is %d\n", rc);
exit(-1);
}
pthread_attr_destroy(&attr);
rc = pthread_join(TInv, &Iid);
if (rc)
{
printf("ERROR; return code from pthread_join() is %d\n", rc);
exit(-1);
}
printf("Thread %ld starting...\n",tid1);
rc = pthread_create(&TSales, &attr, SalesExtract, (void
)&t1);
if(rc)
{
printf("ERROR; return code from SalesExtract pthread_create() is %d\n", rc);
exit(-1);
}
pthread_attr_destroy(&attr);
rc = pthread_join(TSales, &Sid);
if (rc)
{
printf("ERROR; return code from pthread_join() is %d\n", rc);
exit(-1);
}
printf("Thread %ld starting...\n",tid2);
rc = pthread_create(&TShip, &attr, ShipExtract, (void
)&t2);
if(rc)
{
printf("ERROR; return code from ShipmentExtract pthread_create() is %d\n", rc);
exit(-1);
}
pthread_attr_destroy(&attr);
rc = pthread_join(TShip, &Spid);
if (rc)
{
printf("ERROR; return code from pthread_join() is %d\n", rc);
exit(-1);
}
pthread_exit((void
) t);
return 0;
}

/****************************************************************************************************

  •   						MAIN FUNCTION
    

***************************************************************************************************/
int main ()
{
pthread_t MainThread;
long t = 1;
int rc = 0;
/void *status;/
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
printf("\nThe process is starting execution in threads");
rc = pthread_create(&MainThread, &attr, ExtractData, (void
)&t);
if(rc)
{
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}
pthread_attr_destroy(&attr);
rc = pthread_join(MainThread, NULL);
if (rc)
{
printf("ERROR; return code from pthread_join() is %d\n", rc);
exit(-1);
}
pthread_exit(NULL);
printf("A Sample program");
return 0;
}

Please use code tags for posting the source code otherwise it is impossible to follow.

Hi. You can only define variables at the top of a block before any non variable-definition statements in the block. So for your code:

void *ExtractData(void *t,void *t1,void *t2)
{
pthread_t TInv,TSales,TShip;
int i;
int rc = 0;
long tid,tid1,tid2;
double result=0.0;
tid = (long)t;
tid1 = (long)t+1;
tid2 = (long)t+2;
void *Iid;
void *Sid;
void *Spid;

it throws an error when it gets to
void *lid;
because you've done something like
tid=(long)t;
before it. Reorder your code to keep your variable definitions above your statements and you'll be fine.