Solved

how can i initialise the head with pthread_t tid ?

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

827 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