It was long time since I coded in C and now I can't even create linked list :( What might be wrong with NodeType
structure ?
I even tried this example and still I get error similar to this.
I need to create linked list that would run on linux and windows (without huge modification).
I compile using: cl myFile.c
command.
Error message:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved.
unlock.c unlock.c(46) : error C2275: 'Node' : illegal use of this type as an expression unlock.c(17) : see declaration of 'Node' unlock.c(46) : error C2146: syntax error : missing ';' before identifier 'a' unlock.c(46) : error C2065: 'a' : undeclared identifier
Source code:
#include <stdio.h>
#include <windows.h>
#include<stdlib.h>
typedef enum {STABLE, RPUSH, LPUSH} STATUS_TYPE;
typedef struct NodeType
{
struct NodeType* _left;
struct NodeType* _right;
int _value;
}Node;
typedef struct AnchorType
{
struct Node* _mostLeft;
struct Node* _mostRight;
STATUS_TYPE _status;
} Anchor;
Node CreateNode(int data)
{
Node newNode;
newNode._value = data;
newNode._left = NULL;
newNode._right = NULL;
return newNode;
}
int main()
{
Anchor anchor;
anchor._mostLeft = NULL;
anchor._mostRight = NULL;
anchor._status = STABLE;
Node a; //<-- What might be wrong ?
return 0;
}
Thanks for help.