------- Comment #2 from raeburn at raeburn dot org  2007-11-04 10:24 -------
Subject: Re:   New: error while compiling pthread application

On Nov 3, 2007, at 18:32, bhvijaykumar at gmail dot com wrote:
> srtp_impl.c:8: error: expected expression before ?{? token
> srtp_impl.c:9: error: expected expression before ?{? token


> My function looks correct with
>
> connEntities[connid]->rcvWinFillMutex = PTHREAD_MUTEX_INITIALIZER;

No, PTHREAD_MUTEX_INITIALIZER is for static initialization only.   
Depending on the OS, it's probably an aggregate initializer, and may  
look something like "{ 0, SOME_FLAG_HERE, 0 }", so you can imagine  
where the syntax error is coming from.  This isn't a gcc bug, it's a  
bug in the code.

C99 does have a syntax for compound literals that can be used as  
structure values, with a slightly different syntax from what you  
quote above, but the POSIX spec describing PTHREAD_MUTEX_INITIALIZER  
does specifically talk about static initialization, not  
initialization or assignment in general.  For dynamic initialization,  
you should be calling pthread_mutex_init.

(This would've been more appropriate for the gcc-help list.)

Ken


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33991

Reply via email to