CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Mar 2010
    Location
    Melbourne Australia
    Posts
    454

    'NODE' undeclared (first use in this function)

    I am developing a double linked list in C ( development environment ) is QT with mingw32 4.7 gcc / g++ compiler ,

    in the header file I have defined struct as follows
    Code:
    #ifndef LINKEDLIST_H
    #define LINKEDLIST_H
    
    
    #include <stdlib.h>
    #include <sys/stat.h>
    #include <signal.h>
    #ifndef NULL
    #define NULL 0
    #endif
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    /* Function code goees here  */
    
    struct NODE
    {
        char val;
        int  pos;
        struct NODE *previous, *next;
    };
    
    struct NODE *CreateList();
    
    #ifdef __cplusplus
    }
    #endif
    
    
    #endif // LINKEDLIST_H
    and C file

    Code:
    #include "LinkedList.h"
    
    struct NODE *CreateList()
    {
        struct NODE *node;
        node = (NODE *)malloc(sizeof(NODE));
        if(node == NULL){
            return NULL;
        }
        node->pos =0;
        node->previous = NULL;
        node->next = NULL;
        return node;
    }
    when compiling I am getting the following error
    'NODE' undeclared (first use in this function)

    and

    each undeclared identifier is reported only once for each function it appears in

    I have also attached the screen shot from the QT IDE

    look's like the compiler is not able to pick up the definition of NODE structure
    same happens in Netbeans IDE , interesting thing is if change the source file from c to cpp the error goes away .
    Any help would be much appreciated .
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured