Click here to Skip to main content
15,867,488 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
Questionmultiple Pin
memoarfaa16-Apr-15 1:28
memoarfaa16-Apr-15 1:28 
GeneralRe: multiple Pin
Richard MacCutchan16-Apr-15 2:20
mveRichard MacCutchan16-Apr-15 2:20 
QuestionHow to swap address of pointers of 2 variables without using a temporary variable? Pin
Amrit Agr13-Apr-15 20:36
Amrit Agr13-Apr-15 20:36 
AnswerRe: How to swap address of pointers of 2 variables without using a temporary variable? Pin
jschell14-Apr-15 13:17
jschell14-Apr-15 13:17 
AnswerRe: How to swap address of pointers of 2 variables without using a temporary variable? Pin
zhijzan7-Jun-15 20:40
zhijzan7-Jun-15 20:40 
AnswerRe: How to swap address of pointers of 2 variables without using a temporary variable? Pin
Shao Voon Wong28-Jun-15 22:13
mvaShao Voon Wong28-Jun-15 22:13 
Questionhow to migrate CORBA to Web Service in C++ Pin
VC_RYK13-Apr-15 20:20
VC_RYK13-Apr-15 20: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 15:29
Member 1160464113-Apr-15 15: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

C++
#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 21:33
mveRichard MacCutchan13-Apr-15 21:33 
Questionint **p = (int**)new int(5); Confusing !!! Pin
Amrit Agr5-Apr-15 8:32
Amrit Agr5-Apr-15 8:32 
AnswerRe: int **p = (int**)new int(5); Confusing !!! Pin
Richard Andrew x645-Apr-15 10:14
professionalRichard Andrew x645-Apr-15 10:14 
AnswerRe: int **p = (int**)new int(5); Confusing !!! Pin
Zabir Al Nazi Nabil5-Apr-15 11:34
professionalZabir Al Nazi Nabil5-Apr-15 11:34 
Questionsolitaire game Pin
Member 115602925-Apr-15 4:19
Member 115602925-Apr-15 4:19 
AnswerRe: solitaire game Pin
Richard MacCutchan5-Apr-15 5:39
mveRichard MacCutchan5-Apr-15 5:39 
QuestionFast object tracking code Pin
Member 1051522512-Mar-15 22:35
professionalMember 1051522512-Mar-15 22:35 
Questionhow to use hook for mouse simulation Pin
Omarkkk10-Mar-15 2:02
Omarkkk10-Mar-15 2:02 
AnswerRe: how to use hook for mouse simulation Pin
Richard MacCutchan10-Mar-15 6:04
mveRichard MacCutchan10-Mar-15 6:04 
GeneralRe: how to use hook for mouse simulation Pin
Omarkkk10-Mar-15 6:08
Omarkkk10-Mar-15 6:08 
GeneralRe: how to use hook for mouse simulation Pin
Richard MacCutchan10-Mar-15 6:28
mveRichard MacCutchan10-Mar-15 6:28 
GeneralRe: how to use hook for mouse simulation Pin
Omarkkk10-Mar-15 6:37
Omarkkk10-Mar-15 6:37 
GeneralRe: how to use hook for mouse simulation Pin
Richard MacCutchan10-Mar-15 6:58
mveRichard MacCutchan10-Mar-15 6:58 
GeneralRe: how to use hook for mouse simulation Pin
Omarkkk10-Mar-15 7:03
Omarkkk10-Mar-15 7:03 
GeneralRe: how to use hook for mouse simulation Pin
Richard MacCutchan10-Mar-15 7:10
mveRichard MacCutchan10-Mar-15 7:10 
GeneralRe: how to use hook for mouse simulation Pin
Omarkkk10-Mar-15 7:20
Omarkkk10-Mar-15 7:20 
GeneralRe: how to use hook for mouse simulation Pin
Richard MacCutchan10-Mar-15 7:37
mveRichard MacCutchan10-Mar-15 7: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.