LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
LinkBack Search this Thread
Old 09-19-2007, 10:40 PM   #1
jaepi
Member
 
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:
//constructor
X::X(): Z(PTHREAD_COND_INITIALIZER)  
{
//code here  
}


What do you think is the problem?

Thanks!
 
Old 09-20-2007, 01:22 AM   #2
kev82
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.
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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


All times are GMT -5. The time now is 08:51 AM.

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