Thread: Forward declaration with g++

  1. #1
    Registered User
    Join Date
    Jun 2009

    Forward declaration with g++

    In class filter.h, I have the following forward declarations

    template<class T> //Forward declaration due to circular dependency
    class Agc;
    class FixPt;
    class QuantizerCmplx;
    template<class T>
    class Quantizer;

    I get the following errors while compiling with g++.

    ../source/filter.h: In member function ‚int FarrowFilter<T>::filter_quantize()‚:
    ../source/filter.h:1837: error: invalid use of undefined type ‚struct QuantizerCmplx‚
    ../source/filter.h:12: error: forward declaration of ‚struct QuantizerCmplx‚

    How do I solve this problem? It compiles fine with VC++


  2. #2
    Student legit's Avatar
    Join Date
    Aug 2008
    UK -> Newcastle
    Please use code tags. It makes your post so much easier to read.
    Last edited by legit; 06-15-2009 at 09:48 AM.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Lemme guess, rather than insert [code][/code] tags, you decided to do the bone-headed thing and remove all the braces instead, just to stop the board complaining at you.

    Great, now what you posted it utterly meaningless.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    The larch
    Join Date
    May 2006
    It basically says that there is something on line 1837 that requires the full definition of QuantizerCmplx for which a forward declaration alone is not enough.
    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).

  5. #5
    Kung Fu Kitty Angus's Avatar
    Join Date
    Oct 2008
    Montreal, Canada
    The last time I tried to forward declare a template class I failed. I'll bet it has something to do w/that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 04:35 PM
  2. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  3. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM