Solved

how can i initialise the head with pthread_t tid ?

Posted on 2000-03-04
2
723 Views
Last Modified: 2013-12-26
In my project I have the structure defined like this.
/* Defining a structure for storing thread_id ,flag */
/* & expression */


typedef struct data
  {
    pthread_t tid;
    enum BOOLEAN flag;
    char *expr;
    struct data *next;
  }Tdinfo;

there is a finction called initialise_thread in which i am creating new node and initialising the values like this.

Tdinfo *initialise_thread()
{
        Tdinfo *head;
        head=(Tdinfo *)malloc(sizeof(Tdinfo));
        if(head==NULL) /* Null means memory was not allocated */
        {
                Log_Error(fp,"Memory allocation failed ");
                exit(EXIT_STATUS);
        }
        head->tid=0; /* here i want to initialise this tid value to be 0 */
        head->flag=False;
        head->expr=NULL;
        head->next=NULL;
        return(head);
}

The problem is that  the c compiler is giving me the error
error 1527: Incompatible types in cast: Must cas
t from scalar to scalar or to void type.

how to solve this problem ?


In my project I am creating a thread and i am storing the new thread id into the linked list.
0
Comment
Question by:adinarayanak
2 Comments
 
LVL 3

Accepted Solution

by:
ufolk123 earned 10 total points
ID: 2582915
Can not assume pthread_t to be an integer like this.
Use

pthread_t dummy;
memset(dummy,o,sizeof(pthread_t));
head->tid=dummy;
head->flag=False;
       
0
 

Author Comment

by:adinarayanak
ID: 2586945
but these are the compilation errors when i did like that.


cc: "Handle_thread.c", line 39: error 1718: Types are not assignment-compatible.
cc: "Handle_thread.c", line 39: warning 563: Argument #1 is not the correct type


here line 39 is :

memset(dummy,0,sizeof(pthread_t));

please do it.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now