compilation problem

S

shaanxxx

#include<stdio.h>
#include<pthread.h>
int main()
{
return 0;
}

void callCancelHandlerSubscribe (void *param)
{
printf("++++callCancelHandlerSubscribe+++\n");
}

void myfunc ()
{
pthread_cleanup_push(callCancelHandlerSubscribe, 0);
return ;
}


Am I doing any thing wrong here ? i am not able to compile the above
code .

Here are error and compiler information :

SHQ >> cc test.c -lpthread
"test.c", line 21: syntax error before or at: <EOF>
cc: acomp failed for test.c
SHQ >> CC test.c -lpthread
"test.c", line 21: Error: "}" expected instead of EOF.
1 Error(s) detected.
SHQ >> cc -V
cc: Sun WorkShop 6 update 2 C 5.3 2001/05/15
usage: cc [ options] files. Use 'cc -flags' for details
SHQ >> CC -V
CC: Sun WorkShop 6 update 2 C++ 5.3 Patch 111685-19 2003/12/18
 
R

Richard Heathfield

shaanxxx said:

void myfunc ()
{
pthread_cleanup_push(callCancelHandlerSubscribe, 0);
return ;
}


Am I doing any thing wrong here ?


Yes, two things:

Firstly, you're asking a Unix programming question in comp.lang.c instead of
in comp.unix.programmer, and secondly you're invoking a macro without
understanding it (although this is not evident purely from your source
code).

Ask this in comp.unix.programmer: "What else must I do when I invoke
pthread_cleanup_push"? (The hint, as is so often the case, is in the
name...)
 
T

T.M. Sommers

shaanxxx said:
#include<stdio.h>
#include<pthread.h>
int main()
{
return 0;
}

void callCancelHandlerSubscribe (void *param)
{
printf("++++callCancelHandlerSubscribe+++\n");
}

void myfunc ()
{
pthread_cleanup_push(callCancelHandlerSubscribe, 0);
return ;
}


Am I doing any thing wrong here ? i am not able to compile the above
code .

Here are error and compiler information :

SHQ >> cc test.c -lpthread
"test.c", line 21: syntax error before or at: <EOF>
cc: acomp failed for test.c
SHQ >> CC test.c -lpthread
"test.c", line 21: Error: "}" expected instead of EOF.
1 Error(s) detected.
SHQ >> cc -V
cc: Sun WorkShop 6 update 2 C 5.3 2001/05/15
usage: cc [ options] files. Use 'cc -flags' for details
SHQ >> CC -V
CC: Sun WorkShop 6 update 2 C++ 5.3 Patch 111685-19 2003/12/18

It compiles using gcc on FreeBSD, but the code above does not
have 21 lines, as indicated by the error messages, so I suspect
that you are compiling something different.

Also, since the pthread library is not part of standard C, you
might be better off asking in a platform-specific newsgroup.
 
?

=?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=

shaanxxx said:
#include<stdio.h>
#include<pthread.h>
int main()
{
return 0;
}

void callCancelHandlerSubscribe (void *param)
{
printf("++++callCancelHandlerSubscribe+++\n");
}

void myfunc ()
{
pthread_cleanup_push(callCancelHandlerSubscribe, 0);
return ;
}


Am I doing any thing wrong here ? i am not able to compile the above
code .

Here are error and compiler information :

SHQ >> cc test.c -lpthread
"test.c", line 21: syntax error before or at: <EOF>
cc: acomp failed for test.c
SHQ >> CC test.c -lpthread
"test.c", line 21: Error: "}" expected instead of EOF.
1 Error(s) detected.
SHQ >> cc -V
cc: Sun WorkShop 6 update 2 C 5.3 2001/05/15
usage: cc [ options] files. Use 'cc -flags' for details
SHQ >> CC -V
CC: Sun WorkShop 6 update 2 C++ 5.3 Patch 111685-19 2003/12/18

Read the documentation for pthread_cleanup_push, it has something very
important to say about it which includes pthread_cleanup_pop.

As as side note, on many implementation these calls are not functions,
but rather macros.
 
S

shaanxxx

Richard said:
shaanxxx said:




Yes, two things:

Firstly, you're asking a Unix programming question in comp.lang.c instead of
in comp.unix.programmer, and secondly you're invoking a macro without
understanding it (although this is not evident purely from your source
code).

I asked this question on this group because this group is 'the most
active group'.
Ask this in comp.unix.programmer: "What else must I do when I invoke
pthread_cleanup_push"? (The hint, as is so often the case, is in the
name...)

--

I have put this question on comp.unix.programmer.



Thanks
 
M

Martin Ambuhl

shaanxxx said:
#include<stdio.h>
#include<pthread.h>
int main()
{
return 0;
}

void callCancelHandlerSubscribe (void *param)
{
printf("++++callCancelHandlerSubscribe+++\n");
}

void myfunc ()
{
pthread_cleanup_push(callCancelHandlerSubscribe, 0);
return ;
}


Am I doing any thing wrong here ? i am not able to compile the above
code .

Here are error and compiler information :

SHQ >> cc test.c -lpthread
"test.c", line 21: syntax error before or at: <EOF>
cc: acomp failed for test.c
SHQ >> CC test.c -lpthread
"test.c", line 21: Error: "}" expected instead of EOF.
1 Error(s) detected.

I would suggest that the above is not your real code, since it seems not
to have anything to generate such diagnostics. Try the below, which has
been cleaned up sufficiently to be topical in <
#include <stdio.h>
#if 0
/* mha: <pthread.h> is not a standard header, so I have commented out
the next line. */
#include <pthread.h>
#endif

/* mha: since there is no standard function pthread_cleanup_push(), I
have added this definition. */
void pthread_cleanup_push(void f(void *), int q)
{
}

int main(void)
{
return 0;
}

void callCancelHandlerSubscribe(void *param)
{
printf("++++callCancelHandlerSubscribe+++\n");
}

void myfunc()
{
pthread_cleanup_push(callCancelHandlerSubscribe, 0);
}
 
S

shaanxxx

Nils said:
shaanxxx said:
#include<stdio.h>
#include<pthread.h>
int main()
{
return 0;
}

void callCancelHandlerSubscribe (void *param)
{
printf("++++callCancelHandlerSubscribe+++\n");
}

void myfunc ()
{
pthread_cleanup_push(callCancelHandlerSubscribe, 0);
return ;
}


Am I doing any thing wrong here ? i am not able to compile the above
code .

Here are error and compiler information :

SHQ >> cc test.c -lpthread
"test.c", line 21: syntax error before or at: <EOF>
cc: acomp failed for test.c
SHQ >> CC test.c -lpthread
"test.c", line 21: Error: "}" expected instead of EOF.
1 Error(s) detected.
SHQ >> cc -V
cc: Sun WorkShop 6 update 2 C 5.3 2001/05/15
usage: cc [ options] files. Use 'cc -flags' for details
SHQ >> CC -V
CC: Sun WorkShop 6 update 2 C++ 5.3 Patch 111685-19 2003/12/18

Read the documentation for pthread_cleanup_push, it has something very
important to say about it which includes pthread_cleanup_pop.

Got it :)

Thanks
 
R

Richard Heathfield

shaanxxx said:
I asked this question on this group because this group is 'the most
active group'.

In which case I suggest you send future questions to alt.test, which is even
more active than comp.lang.c.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,078
Messages
2,570,572
Members
47,204
Latest member
MalorieSte

Latest Threads

Top