incomplete type and cannot be defined
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: incomplete type and cannot be defined

  1. #1
    Join Date
    Jun 2008
    Posts
    4

    incomplete type and cannot be defined

    Hi, im having problems with a project I am working on. It is a class that creates an xlib window. Here is the code:

    main.cpp
    Code:
    #include <X11/Xlib.h>
    #include "ys_window.h"
    
    int main(){
    
        //window object
        ys_window wind;
    
        wind.showwindow(true);
    
        while(1){
            XEvent e;
        }
    
        return 0;
    }
    ys_window.h
    Code:
    #ifndef YS_WINDOW_H_INCLUDED
    #define YS_WINDOW_H_INCLUDED
    
        class ys_window;
    
    #endif // YS_WINDOW_H_INCLUDED
    ys_window.cpp
    Code:
    #include <X11/Xlib.h>
    #include <cairo.h>
    #include <cairo-xlib.h>
    
    class ys_window{
        private:
            int xsize;
            int ysize;
            int xpos;
            int ypos;
    
            bool visible;
    
            //cairo variables
            cairo_surface_t *cs;
            cairo_t *c;
    
            //xlib variables
            Display *dpy;
            int blackcolour;
            Window w;
    
        public:
            ys_window(){
                //set the default values to create the window
                xsize = 200;
                ysize = 200;
                xpos = 200;
                ypos = 200;
    
                //the xlib display variable
                dpy = XOpenDisplay(0);
    
                //colour used to blackout the window
                blackcolour = BlackPixel(dpy, DefaultScreen(dpy));
    
                //create the window
                w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), xpos, ypos, xsize, ysize, 0, blackcolour, blackcolour);
    
                XFlush(dpy);
    
            };
    
            void showwindow(bool visible);
    };
    
    void ys_window::showwindow(bool vis)
    {
        if(vis == true){
    
            XMapWindow(dpy, w);
    
        }else{
    
            XUnmapWindow(dpy, w);
    
        }
    
        XFlush(dpy);
        visible = vis;
    }
    I keep getting the error "/root/Development/ys_framework/main.cpp|7|error: aggregate ‘ys_window wind’ has incomplete type and cannot be defined|"

  2. #2
    Join Date
    Apr 1999
    Posts
    27,444

    Re: incomplete type and cannot be defined

    Quote Originally Posted by iamhere
    Hi, im having problems with a project I am working on. It is a class that creates an xlib window. Here is the code:
    Code:
        //window object
        ys_window wind;
    You need to redo everything.

    When the compiler encounters this statement, you must have the full definition of ys_window available to the compiler. The header file only contains a forward declared class.

    Why is your ys_window class defined in your .cpp file??
    Code:
    #ifndef YS_WINDOW_H_INCLUDED
    #define YS_WINDOW_H_INCLUDED
    
    // other include files...
    
    class ys_window{
        private:
            int xsize;
            int ysize;
            int xpos;
            int ypos;
    
            bool visible;
    
            //cairo variables
            cairo_surface_t *cs;
            cairo_t *c;
    
            //xlib variables
            Display *dpy;
            int blackcolour;
            Window w;
    
        public:
            ys_window();
            void showwindow(bool visible);
    };
    #endif // YS_WINDOW_H_INCLUDED
    This is what should have been in your header. You will also have to add #includes in this header to resolve the new outstanding problems (i.e. Window not being defined, Display not being defined, etc.)

    Regards,

    Paul McKenzie

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center