Click here to Skip to main content
14,385,373 members

Managed C++/CLI

 
Questionmultiple Pin
memoarfaa16-Apr-15 2:28
Membermemoarfaa16-Apr-15 2:28 
GeneralRe: multiple Pin
Richard MacCutchan16-Apr-15 3:20
mveRichard MacCutchan16-Apr-15 3:20 
QuestionHow to swap address of pointers of 2 variables without using a temporary variable? Pin
Amrit Agr13-Apr-15 21:36
MemberAmrit Agr13-Apr-15 21:36 
AnswerRe: How to swap address of pointers of 2 variables without using a temporary variable? Pin
jschell14-Apr-15 14:17
Memberjschell14-Apr-15 14:17 
AnswerRe: How to swap address of pointers of 2 variables without using a temporary variable? Pin
zhijzan7-Jun-15 21:40
Memberzhijzan7-Jun-15 21:40 
AnswerRe: How to swap address of pointers of 2 variables without using a temporary variable? Pin
Shao Voon Wong28-Jun-15 23:13
mvaShao Voon Wong28-Jun-15 23:13 
Questionhow to migrate CORBA to Web Service in C++ Pin
VC_RYK13-Apr-15 21:20
MemberVC_RYK13-Apr-15 21:20 
Questionconsumer.C: In function âint main(int, char**)â: consumer.C:69: error: invalid conversion from âvoid (*)(buffer_t*, char)â to âvoid* (*)(void*)â consumer.C:69: error: initializing argument 3 of âint pthread_create(pthread_t*, const pthread_attr_t*, Pin
Member 1160464113-Apr-15 16:29
MemberMember 1160464113-Apr-15 16:29 
I've been getting this error when I compile in my Consumer/Producer Multi-threaded program. Can someone please help me Smile | :) ? Here is my code

#include <iostream>
#include <stdio.h>
#include <pthread.h>
#include <assert.h>
#include<complex>

# define BSIZE 10
# define NUM_THREADS 5
using namespace std;


typedef struct {
  char buf[BSIZE];
  int occupied;
  int nextin;
  int nextout;
  pthread_mutex_t mutex;
  pthread_cond_t more;
  pthread_cond_t less;
} buffer_t;

buffer_t buffer;

void producer(buffer_t *b, char item)
{
  pthread_mutex_lock(&b->mutex);

  while (b->occupied >= BSIZE)
    pthread_cond_wait(&b->less, &b->mutex);

  assert(b->occupied < BSIZE);

  b->buf[b->nextin++] = item;

  b->nextin %= BSIZE;
  b->occupied++;
  pthread_cond_signal(&b->more);

  pthread_mutex_unlock(&b->mutex);
}

char consumer(buffer_t *b)
{
  char item;
  pthread_mutex_lock(&b->mutex);
  while(b->occupied <= 0)
    pthread_cond_wait(&b->more, &b->mutex);

  assert(b->occupied > 0);

  item = b->buf[b->nextout++];
  b->nextout %= BSIZE;
  b->occupied--;

  pthread_cond_signal(&b->less);
  pthread_mutex_unlock(&b->mutex);

  return(item);
}

int main(int argc, char* argv[] )
{


  pthread_t ptid;
  pthread_attr_t attr;

  pthread_attr_init(&attr); /* initialize attr with default attributes */
 pthread_create(&ptid, &attr, producer  , NULL);



}


modified 13-Apr-15 22:13pm.

AnswerRe: consumer.C: In function âint main(int, char**)â: consumer.C:69: error: invalid conversion from âvoid (*)(buffer_t*, char)â to âvoid* (*)(void*)â consumer.C:69: error: initializing argument 3 of âint pthread_create(pthread_t*, const pthread_attr Pin
Richard MacCutchan13-Apr-15 22:33
mveRichard MacCutchan13-Apr-15 22:33 
Questionint **p = (int**)new int(5); Confusing !!! Pin
Amrit Agr5-Apr-15 9:32
MemberAmrit Agr5-Apr-15 9:32 
AnswerRe: int **p = (int**)new int(5); Confusing !!! Pin
Richard Andrew x645-Apr-15 11:14
professionalRichard Andrew x645-Apr-15 11:14 
AnswerRe: int **p = (int**)new int(5); Confusing !!! Pin
Zabir Al Nazi Nabil5-Apr-15 12:34
professionalZabir Al Nazi Nabil5-Apr-15 12:34 
Questionsolitaire game Pin
Member 115602925-Apr-15 5:19
MemberMember 115602925-Apr-15 5:19 
AnswerRe: solitaire game Pin
Richard MacCutchan5-Apr-15 6:39
mveRichard MacCutchan5-Apr-15 6:39 
QuestionFast object tracking code Pin
Member 1051522512-Mar-15 23:35
professionalMember 1051522512-Mar-15 23:35 
Questionhow to use hook for mouse simulation Pin
Omarkkk10-Mar-15 3:02
MemberOmarkkk10-Mar-15 3:02 
AnswerRe: how to use hook for mouse simulation Pin
Richard MacCutchan10-Mar-15 7:04
mveRichard MacCutchan10-Mar-15 7:04 
GeneralRe: how to use hook for mouse simulation Pin
Omarkkk10-Mar-15 7:08
MemberOmarkkk10-Mar-15 7:08 
GeneralRe: how to use hook for mouse simulation Pin
Richard MacCutchan10-Mar-15 7:28
mveRichard MacCutchan10-Mar-15 7:28 
GeneralRe: how to use hook for mouse simulation Pin
Omarkkk10-Mar-15 7:37
MemberOmarkkk10-Mar-15 7:37 
GeneralRe: how to use hook for mouse simulation Pin
Richard MacCutchan10-Mar-15 7:58
mveRichard MacCutchan10-Mar-15 7:58 
GeneralRe: how to use hook for mouse simulation Pin
Omarkkk10-Mar-15 8:03
MemberOmarkkk10-Mar-15 8:03 
GeneralRe: how to use hook for mouse simulation Pin
Richard MacCutchan10-Mar-15 8:10
mveRichard MacCutchan10-Mar-15 8:10 
GeneralRe: how to use hook for mouse simulation Pin
Omarkkk10-Mar-15 8:20
MemberOmarkkk10-Mar-15 8:20 
GeneralRe: how to use hook for mouse simulation Pin
Richard MacCutchan10-Mar-15 8:37
mveRichard MacCutchan10-Mar-15 8:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.