ERROR: aggregate has incomplete type and cannot be defined

This is a discussion on ERROR: aggregate has incomplete type and cannot be defined within the C++ Programming forums, part of the General Programming Boards category; Hi all, I'm writing the following class for digital image inpainting: http://graphics.csie.ntu.edu.tw/~jon...mgPlane.h.html http://graphics.csie.ntu.edu.tw/~jon...Plane.cpp.html However, when I compile, I get the ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    33

    ERROR: aggregate has incomplete type and cannot be defined

    Hi all,

    I'm writing the following class for digital image inpainting:
    http://graphics.csie.ntu.edu.tw/~jon...mgPlane.h.html
    http://graphics.csie.ntu.edu.tw/~jon...Plane.cpp.html

    However, when I compile, I get the following error:
    FBInpainting/imgPlane.cpp: In member function ‘void imgPlane::writeLine(pixel, pixel, int, int)’:
    FBInpainting/imgPlane.cpp:207: error: aggregate ‘pixel now’ has incomplete type and cannot be defined

    I'm not sure what is "incomplete type", actually, I have no forward reference, etc.
    So, I have no idea how to fix this error.
    Any suggestion?

    As the definition of pixel, please refer to the lines 21 ~ 23 of the header file.

    Thanks a lot!

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Could you provide the code as an attachment (without the line numbers and without parts that depend on additional header, so it is a minimal compilable example that produces your problem)?

    I don't see anything really wrong except that the signatures of writeLine are a bit ambiguous because of the default parameter. (Perhaps try removing the first overload altogether since it doesn't add anything)

    You also don't need to use the struct keyword when declaring instances in C++ (unlike C) but that should have nothing to do with the problem.
    Last edited by anon; 01-15-2008 at 09:07 AM.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    You may have a conflict between a GIL identifier and your own struct pixel. I'm not sure if GIL contains anything called pixel, but I wouldn't be surprised.

    That's why you shouldn't import complete namespaces.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    33
    To anon:
    Here is the compilable example:
    http://graphics.csie.ntu.edu.tw/~jon...temp/trunk.tar
    If you're running *NIX OS, simply type "make" to compile.
    However, the source code depends on GUI library FLTK and Boost gil...
    FLTK: http://www.fltk.org/
    Boost gil: http://stlab.adobe.com/gil/documentation.html

    Besides, if I use simply "pixel" rather than "struct pixel"
    compiler will complain about "ambiguous reference to pixel"
    Maybe its result from the the namespace conflict in boost::gil:: pixel and my own pixel

    To CornedBee:
    Yeah, you're right.
    boost::gil also has its own struct pixel
    So, what is the recommended solution to this problem?
    Though, I know I can either rename my own pixel to my_pixel or something similar,
    or reference every member in gil by specify the full namespace like boost::gil::some_member.
    Last edited by jutirain; 01-15-2008 at 06:45 PM.

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    I'd alias the gil namespace to
    namespace gil = boost::gil;
    and then explicitly qualify everything.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21