Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

Error compiling posix threds program?

 
SOLVED
Go to solution
Highlighted
Occasional Advisor

Error compiling posix threds program?

Hi,

Why this program doesn't compile?


<>

m3vmsa3.extpex /tmp > cat kk.c
#include

void TPV_closing_state(void *arg){}

int main()
{
void *obj= 0L ;
pthread_cleanup_push(TPV_closing_state, (void *)obj);
}
m3vmsa3.extpex /tmp > aCC -AA -D_POSIX_THREADS_ -D_RWSTD_MULTI_THREAD kk.c
Error 20: "kk.c", line 8679 # '}' expected before ''.
m3vmsa3.extpex /tmp > aCC -V
aCC: HP ANSI C++ B3910B A.03.27

<>



Thanks in advance,
Jose Luis
3 REPLIES 3
Highlighted

Re: Error compiling posix threds program?

>Why this program doesn't compile?

Is pthread_cleanup_push(3t) defined in ? What OS version are you using?

A.03.27 is obsolete, the latest is A.03.85.
(If -mt is supported, you should use that.)
Highlighted
Occasional Advisor

Re: Error compiling posix threds program?


Hi,

This is my OS version and the code generated with the "-P" option:


<>

m3vmsa3.extpex /tmp > aCC -P -AA -D_POSIX_THREADS_ -D_RWSTD_MULTI_THREAD kk.c
m3vmsa3.extpex /tmp > tail -6 kk.i
void TPV_closing_state(void *arg){}
int main()
{
void *obj= 0L ;
{ __pthread_cleanup_handler_t __handler, **__handler_queue; __handler.__handler_function = TPV_closing_state; __handler.__handler_arg = (void *)obj; __handler_queue = (__pthread_cleanup_handler_t **)(__pthread_cancel_stack()); __handler.__next_handler = *__handler_queue; *__handler_queue = &__handler; ;
}
m3vmsa3.extpex /tmp > uname -a
HP-UX m3vmsa3 B.11.00 U 9000/800 178951547 unlimited-user license
m3vmsa3.extpex /tmp > aCC -mt -AA -D_POSIX_THREADS_ -D_RWSTD_MULTI_THREAD kk.c
aCC: warning 901: unknown option: `-mt': use +help for online documentation.
Error 20: "kk.c", line 8679 # '}' expected before ''.

<>


Is is strange, the precompiled code has an extra "}".

The "-mt" option is not supported.

Regards,
Jose Luis.
Highlighted
Solution

Re: Error compiling posix threds program?

>the code generated with the "-P" option:

A better option is: -E -.i

>B.11.00

This isn't supported.

>Is it strange, the precompiled code has an extra "}".

It appears these are macros and you need to use them in pairs:
pthread_cleanup_push(TPV_closing_state, (void*)obj);
; // stuff
pthread_cleanup_pop(true);