Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how can i initialise the head with pthread_t tid ?

Posted on 2000-03-04
2
Medium Priority
?
800 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
ufolk123 earned 30 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

618 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