By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,852 Members | 2,219 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,852 IT Pros & Developers. It's quick & easy.

compilation problem

P: n/a
#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

Sep 27 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
shaanxxx said:

<snip>
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...)

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Sep 27 '06 #2

P: n/a
shaanxxx wrote:
#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.

--
Thomas M. Sommers -- tm*@nj.net -- AB2SB

Sep 27 '06 #3

P: n/a
shaanxxx wrote:
#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.

Sep 27 '06 #4

P: n/a

Richard Heathfield wrote:
shaanxxx said:

<snip>
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).
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

Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Sep 27 '06 #5

P: n/a
shaanxxx wrote:
#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 <news:comp.lang.c>:

#include <stdio.h>
#if 0
/* mha: <pthread.his 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);
}

Sep 27 '06 #6

P: n/a

Nils O. Selåsdal wrote:
shaanxxx wrote:
#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

Sep 27 '06 #7

P: n/a
shaanxxx said:
>
Richard Heathfield wrote:
>shaanxxx said:
<snip>
>>
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).

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.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Sep 27 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.