Solved

how can i initialise the head with pthread_t tid ?

Posted on 2000-03-04
2
736 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

930 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

10 Experts available now in Live!

Get 1:1 Help Now