473,395 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

warning: assignment from incompatible pointer type

thatos
105 100+
I have the following code
Expand|Select|Wrap|Line Numbers
  1. typedef struct _DoublyLinkedNode {
  2.     int value;
  3.     struct _DoublyLinkedNode *next;
  4.     struct _DoublyLinkedNode *prev;
  5. }DoublyLinkedNode;
  6.  
  7. typedef struct DoublyLinkedList {
  8.     int size;
  9.     struct DoublyLinkedNode *firstnode;
  10.     struct DoublyLinkedNode *lastnode;
  11. }list;
  12.  
  13.  
  14. list *p;
  15.  
  16. int main(){
  17.     p = (list*)malloc(sizeof(list));
  18.     DoublyLinkedNode *node;
  19.     node = (DoublyLinkedNode*)malloc(sizeof(DoublyLinkedNode));
  20.     node->value = 7;
  21.     node->next = NULL;
  22.     node->prev = NULL;
  23.     /*
  24.     The other code belongs here.
  25.     */
  26.     return 0;
  27. }
  28.  
When I try to do the following:-
Expand|Select|Wrap|Line Numbers
  1. p->firstnode = &node;
  2.  
I get the above warning.
May 19 '11 #1
1 10159
Banfa
9,065 Expert Mod 8TB
assignment from incompatible pointer type means that you are assigning a value to a pointer variable from a pointer of a different and incompatible type.

In your code that means that p->firstnode and &node are both pointers but the types are not compatible for assignment. So you probably need to ask and answer the question what are the types of those 2 expressions.
May 20 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Brian Stubblefield | last post by:
Dear clc members, I am rather new to the C programming language. I have a rather large program that I am currently debugging. Currently, the following snippet of code in the c program: ...
15
by: Chris Readle | last post by:
Hi all, Somewhat new to C and I'm getting the following error from my latest code. Here's the warning I'm getting: chris_readle_project3_assignment3.c: In function `main':...
1
by: Josh Wilson | last post by:
Hey gang, So I have my stdin which is user defined file, and am wanting to write it to a temporary file (seems odd I know, but there is a sincere reason), and then use that file as the stdin for...
6
by: PraZ | last post by:
Hi all. Here is a simple code, which when compiled with gcc results in the warning "incompatible pointer type" for arg 1, as expected. But this is just what I want to do, because it makes it...
8
by: Michael | last post by:
Hi all, why do I get a message: warning: passing arg 1 of `collectInput' from incompatible pointer type In 'main' have: char inputString; collectInput(&inputString);
1
by: wanglei0214 | last post by:
I compiles a program in SLOS, but there is a warning i donot know how to remove? here is the framework of the code: typedef struct device_tree { ...... union {
13
by: william | last post by:
code segment: long int * size; char entry; ............. size=&entry; ************************************* Gcc reported 'assignment of incompatible pointer type'.
10
drhowarddrfine
by: drhowarddrfine | last post by:
warning: assignment makes pointer from integer without a cast I get that when I compile a C file where the function is defined as this: char **getvars() and the calling function has this...
5
by: plazzasele | last post by:
I want to register a new Person by using the set and get method. I am running my code on a program ( DEVc++), and when i compile the code i get this error message: assignment from incompatible...
6
by: suvas | last post by:
I have C code. On compliation it shows error, warning: assignment from incompatible pointer type Actually I wanted to evaluate integral then sum all the integrals. I would be glad if anyone could...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.