Thread: "error: incomplete type is not allowed"

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    King of the Internet Fahrenheit's Avatar
    Join Date
    Oct 2001
    Posts
    128

    "error: incomplete type is not allowed"

    I've been coding for a long time, and never have I faced this error message before. I am writing a compiler for a language that dynamically compiles itself on other platforms.. while the specifications for that are not the problem, it's an odd problem I got when I tried "modularizing" my applications with C++ and classes.


    Code:
    struct Type ;
      struct Class ;
      struct Function ;
      struct Variable ;
      struct Definition ;
      
      typedef std::deque<std::string> StringList ;
      typedef StringList::iterator RegisteredString;
    
      typedef std::deque<Type> TypeList ;
      typedef TypeList::iterator RegisteredType;
    
      typedef std::deque<Class> ClassList ;
      typedef ClassList::iterator RegisteredClass;
    
      typedef std::deque<Variable> VariableList ;
      typedef VariableList::iterator RegisteredVariable ;
    
      typedef std::deque<Function> FunctionList ;
      typedef FunctionList::iterator RegisteredFunction ;
    
      enum Level {
    	Private, Public, Protected
      } ;
    
    #include <Type.hpp> // requires class
    #include <Variable.hpp> // requires type
    #include <Function.hpp> // requires type / variable
    #include <Class.hpp> // requires variable / function
    #include <Definition.hpp> // requires everything
    Type.hpp

    Code:
    struct TETRA Type 
    {
      RegisteredClass rc ;
      dword array_depth ;
      dword flags ;
    
      operator == (const Type & t) ;
      operator != (const Type & t) ;
    } ;
    Variable.hpp

    Code:
    struct TETRA Variable 
    {
      RegisteredString name ;
      RegisteredType type ;
    
      Level level ;
    
      operator== (const Variable & v) ;
      operator!= (const Variable & v) ;
    
      operator== (const Function & f) ;
      operator!= (const Function & f) ;
    
      operator== (const Class & c) ;
      operator!= (const Class & c) ; 
    
      operator std::string () ;
    } ;
    Function.hpp

    Code:
    struct TETRA Function 
    {
      RegisteredString name ;
      RegisteredType type ;
      Level level ;
    
      VariableList arguments ;
      VariableList variables ;
    
      RegisteredVariable AddVariable (const Variable & v) ;
      RegisteredVariable AddArgument (const Variable & v) ;
    
      operator== (const Variable & v) ;
      operator!= (const Variable & v) ;
    
      operator== (const Function & f) ;
      operator!= (const Function & f) ;
    
      operator== (const Class & c) ;
      operator!= (const Class & c) ;
    
      operator std::string () ;
    } ;
    Class.hpp
    Code:
    struct TETRA Class 
    {
      RegisteredString name ;
    
      VariableList members ;
      FunctionList functions ;
    
      operator== (const Variable & v) ;
      operator!= (const Variable & v) ;
    
      operator== (const Function & f) ;
      operator!= (const Function & f) ;
    
      operator== (const Class & c) ;
      operator!= (const Class & c) ;
    
      operator std::string() ;
    
      RegisteredVariable AddMember (const Variable & v) ;
      RegisteredFunction AddFunction (const Function & f) ;
    }
    ;
    Definition.hpp ( I don't think it matters, but whatever. )

    Code:
    struct TETRA Definition
    {
      StringList strings ;
      TypeList types ;
      ClassList classes ;
    
      Definition () ;
    
      RegisteredType AddType (const Type & t) ;
    
      inline idx GetTypeIndex (const RegisteredType rt) {
    	return (idx) (rt - types.begin()) ;
      }
      
      void ReadTypes (std::istream & is, dword count) ;
      void WriteTypes (std::ostream & os) ;
    
      RegisteredString AddString (const std::string & s) ;
      
      inline idx GetStringIndex (const RegisteredString rs) {
    	return (idx) ( rs - strings.begin () ) ;
      }
    
      void WriteStrings (std::ostream & os) ;
      void ReadStrings (std::istream & is, dword count) ;
    
      RegisteredClass AddClass (const Class & c) ;
    
      RegisteredClass FindClass (const std::string & s) ;
      RegisteredClass FindClass (const RegisteredString s) ;
    
      void Read (std::istream & is, dword flags) ;
      void Write (std::ostream & os, dword flags) ;
    
      ~Definition () ;
    } ;
    I get about ~60 error messages from the headers, usually something like

    Compiling with Intel C++ 8.0
    String.cpp
    c:\Program Files\Microsoft Visual Studio .NET\Vc7/include/deque(59): error: incomplete type is not allowed
    _DEQUESIZ = sizeof (_Ty) <= 1 ? 16
    ^
    detected during instantiation of class "std::deque<_Ty, _Ax> [with _Ty=Tetra::Type, _Ax=std::allocator<Tetra::Type>]" at line 49 of "D:\tetra\runtime\Tetra.hpp"

    I can paste them all if necessary, I don't want the flood this topic however. Any help is appreciated, and if you have questions about what I am doing in the code just ask. My forte is C and lowish level stuff, I'm really just now starting to dabble in STL and C++.

    Thanks in advance.
    Last edited by w00tsoft; 05-08-2005 at 08:32 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 03-20-2008, 07:59 AM
  2. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  3. Compiler "Warnings"
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 04-24-2005, 01:09 PM
  4. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 12:22 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM