Compilation Error


 
Thread Tools Search this Thread
Top Forums Programming Compilation Error
# 1  
Old 05-28-2009
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;
}

Last edited by yschd; 05-28-2009 at 08:34 PM..
# 2  
Old 05-28-2009
Please use code tags for posting the source code otherwise it is impossible to follow.
# 3  
Old 06-01-2009
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pro*c compilation error

Hi, Recently our codes have been migrated to new server, whenever we compile any pro*c programs we receive the following errorl. please help >> make -f lib_util.mk all CC= ucbcc 4Compiling lib_util ### command line files and options (expanded): ### -xO3 -DNULL=0 -v -o lib_util.o... (1 Reply)
Discussion started by: satvd
1 Replies

2. Programming

pro*c compilation error

Hi, Recently our codes have been migrated to new server, whenever we compile any pro*c programs we receive the following errorl. please help >> make -f lib_util.mk all CC= ucbcc 4Compiling lib_util ### command line files and options (expanded): ### -xO3 -DNULL=0 -v -o lib_util.o... (0 Replies)
Discussion started by: satvd
0 Replies

3. Programming

Compilation error : Please help

state_field state_abvr = { "AL","ALABAMA", "AK","ALASKA", "AZ","ARIZONA", "AR","ARKANSAS", "CA","CALIFORNIA", "CO","COLORADO", "CT","CONNECTICUT", "DE","DELAWARE", "DC","DISTRICT-OF-COLUMBIA", "FL","FLORIDA", "GA","GEORGIA", "HI","HAWAII", "ID","IDAHO", "IL","ILLINOIS",... (1 Reply)
Discussion started by: jagan_kalluri
1 Replies

4. UNIX for Dummies Questions & Answers

Need help in resolving Compilation error

state_field state_abvr = { "AL","ALABAMA", "AK","ALASKA", "AZ","ARIZONA", "AR","ARKANSAS", "CA","CALIFORNIA", "CO","COLORADO", "CT","CONNECTICUT", "DE","DELAWARE", "DC","DISTRICT-OF-COLUMBIA", "FL","FLORIDA", "GA","GEORGIA", "HI","HAWAII", "ID","IDAHO", "IL","ILLINOIS",... (1 Reply)
Discussion started by: jagan_kalluri
1 Replies

5. HP-UX

compilation error

hello everyone, here i am attempting to compile a c++ submodule.OS is HP-UX. here i am getting the following error. ====================================== "Make: Don't know how to make compile. Stop." =================================== could you pls somebody suggest why this error is... (2 Replies)
Discussion started by: mannam srinivas
2 Replies

6. Linux

c++ compilation error

Hello every one, here i am attempting to compile a c++ module using gcc.it is throwing a error . error: ==== > make -S dummyCHARGP /usr/local/bin/gcc -g -DDEBUG -DMAT -I. -I/swtemp/usbs/cc/unix-ce/root/subsys/lib/Linux/ -I/opt/dce/include -I/opt/dce/include/dce ... (12 Replies)
Discussion started by: mannam srinivas
12 Replies

7. Solaris

Solaris : compilation error

Hi All, while building, i am receiving the following error...... Undefined first referenced symbol in file void os_directory::create(const std::string &) obj.release/BOConfig.o (symbol belongs to implicit dependency... (2 Replies)
Discussion started by: vinod_kumar_k
2 Replies

8. Programming

Compilation error

I am compiling a software xchm on solaris 10. First i run './configure' There is no error. But when i start compiling using 'gmake' following error shown /usr/local/include/wx-2.6/wx/x11/brush.h: In copy constructor `wxBrush::wxBrush(const wxBrush&)':... (3 Replies)
Discussion started by: mansoorulhaq
3 Replies

9. Programming

compilation error

Hi, While trying compile a C++ file in UNIX with gcc whose make rule involves the usage of /usr/ccs/bin/as, I get the following error: /usr/ccs/bin/as: No such file or directory /usr/ccs/bin/as: error: write error on output file "<filename>.o" *** Error code 1 clearmake: Error: Build... (2 Replies)
Discussion started by: smanu
2 Replies

10. Programming

Regarding compilation error.

Hi All, I facing the following compilation error; when I implementing the following logic. ostrstream ostr; ostr << (( scAxsm.getRecord( i ).getField( 2 ).getShort())%12)!=0?(( scAxsm.getRecord( i ).getField( 2 ).getShort())/12+1) : (( scAxsm.getRecord( i ).getField( 2 ).getShort())/12) <<... (1 Reply)
Discussion started by: sweta
1 Replies
Login or Register to Ask a Question