Last active
December 30, 2015 15:08
-
-
Save prufrock/7845995 to your computer and use it in GitHub Desktop.
keeps warning me "initialization from incompatible pointer type [enabled by default]"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "linkedlist.h" | |
int_node linked_list(int data, int_node *link) | |
{ | |
int_node l = {data, link}; | |
return l; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct int_node { int data; // The elemnent stored in this node struct int_node *link; // Refers to the next node in the list } int_node; int_node linked_list(int data, int_node *link); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "linkedlist.h" | |
#include <stdio.h> | |
int main() | |
{ | |
puts("loaded"); | |
} |
I fixed the issue in the previous commit by adding a proper name to the struct 'int_node' rather than just giving it a type_def name. It turns out a struct has to have a proper name when it refers to itself.
I can't compile the code due to the error: "linkedlist.h:1:1: error: unknown type name ‘int_node’":
https://gist.github.com/prufrock/7845995/fe8a918d5143b24501f0be2226d100b96946825c
I fixed the compile error by adding the struct to the header file in this commit: https://gist.github.com/prufrock/7845995/e89aa648eb9e6de2a04505526b8557c2c774e61a
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
keeps warning me "initialization from incompatible pointer type [enabled by default]"