Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-19-2007, 11:40 PM   #1
Registered: Apr 2007
Location: Urban Jungle
Distribution: Ubuntu
Posts: 189
Blog Entries: 1

Rep: Reputation: 30
Help: Initialize pthread_cond_t

Hello there, I've been messing around with threads these days. Currently, I'm having problems with one of my variables of type pthread_cond_t (let's call it variable Z). I made a class (let's say class X) , and you guessed it right, Z was declared in it with private access level. Now the problem here is the initialization of Z. I initialized it with this value - PTHREAD_COND_INITIALIZER. It produces this error - error: expected primary-expression before '{' token.

This is the way I initialized it.

//code here  

What do you think is the problem?

Old 09-20-2007, 02:22 AM   #2
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
PTHREAD_COND_INITIALIZER is #defined as an aggregate. On my platform it is {0x3CB0B1BB, {0}}. There is no constructor for pthread_cond_t that accepts an aggregate.

I unfortunately don't have a very good understanding of how aggregates work, and don't know if it is even possible to write a constructor to accept one (I don't think so though). Even if it was, this would require a modification of pthreads to make your code work (very bad idea!).

Bottom line, use pthread_cond_init() in your constructor.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to initialize Postfix? Gins Linux - General 13 08-11-2007 05:43 PM
Zenwalk Initialize matheuslbarros Zenwalk 3 11-11-2006 08:10 PM
Cannot initialize Evolution PsYlTrance Linux - Software 0 05-13-2004 12:59 PM
Network Initialize delphig Linux - Networking 1 03-26-2004 01:26 AM
NVNet won't initialize synecdoche Linux - Hardware 2 01-24-2004 08:33 PM

All times are GMT -5. The time now is 10:00 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration