Solved

how can i initialise the head with pthread_t tid ?

Posted on 2000-03-04
2
772 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 174
matchUp  challenge 9 125
how to use laptop or pad camera in vb.net windows application 2 107
Increment column based of a FK 8 51
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…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

733 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