![]() |
| | #1 |
| King of the Internet Join Date: Oct 2001
Posts: 128
| "error: incomplete type is not allowed" 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
Code: struct TETRA Type
{
RegisteredClass rc ;
dword array_depth ;
dword flags ;
operator == (const Type & t) ;
operator != (const Type & t) ;
} ;
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 () ;
} ;
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 () ;
} ;
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) ;
}
;
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 () ;
} ;
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.
__________________ http://www.linear.cc/ Last edited by w00tsoft; 05-08-2005 at 08:32 PM. |
| Fahrenheit is offline | |
| | #2 |
| Registered User Join Date: Aug 2003
Posts: 470
| The problem is that std::deque<C>::deque probably requires the definition of C to be present. For instance, it might have code such as C* c = new C[45]. The compiler cannot allocate memory without knowing the size of C. And without knowing the full type of C, the compiler doesn't know what fields C has. |
| okinrus is offline | |
| | #3 |
| King of the Internet Join Date: Oct 2001
Posts: 128
| Everytime i've encountered something with circular references before, forward declarations have fixed it. Why not in this example?
__________________ http://www.linear.cc/ |
| Fahrenheit is offline | |
| | #4 | |
| Registered User Join Date: Apr 2003
Posts: 2,662
| Quote:
Code: class Car;
class Apple;
class Apple
{
Car aCar;
};
class Car
{
Apple anApple;
};
int main()
{
return 0;
}
| |
| 7stud is offline | |
| | #5 |
| King of the Internet Join Date: Oct 2001
Posts: 128
| I don't see where i'm doing that... I assume it's in some STL container that I don't understand.
__________________ http://www.linear.cc/ |
| Fahrenheit is offline | |
| | #6 |
| Toaster Join Date: Aug 2001
Posts: 2,686
| First file... all the typedefs... then the #includes with the definitions.
__________________ The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop. |
| Zach L. is offline | |
| | #7 |
| King of the Internet Join Date: Oct 2001
Posts: 128
| It's obviously not the typedefs, since what I was doing there is legal. I wrote a small workaround with the typedefs still in front and it worked. I suppose it must be an oddity in Microsoft's implementation of the STL. Code: struct Type ;
struct Class ;
struct Function ;
struct Variable ;
struct Definition ;
template<class T> struct Registered {
T * data ;
idx index ;
Registered () { }
Registered (const Registered<T> & r)
{
data = r.data ;
index = r.index ;
}
Registered(T & d, idx i) {
data = &d ;
index = i ;
}
operator= (const Registered<T> & r)
{
data = r.data ;
index = r.index;
}
T & operator* () const { return *data ; }
} ;
typedef std::deque<std::string> StringList ;
typedef StringList::const_iterator StringIter ;
typedef Registered<std::string> RegisteredString;
typedef std::deque<Type> TypeList ;
typedef Registered<Type> RegisteredType;
typedef std::deque<Class> ClassList ;
typedef Registered<Class> RegisteredClass;
typedef std::deque<Variable> VariableList ;
typedef Registered<Variable> RegisteredVariable ;
typedef std::deque<Function> FunctionList ;
typedef Registered<Function> RegisteredFunction ;
__________________ http://www.linear.cc/ |
| Fahrenheit is offline | |
| | #8 | |
| Registered User Join Date: Aug 2003
Posts: 470
| Quote:
| |
| okinrus is offline | |
| | #9 |
| King of the Internet Join Date: Oct 2001
Posts: 128
| well since I fixed my problem and it works now i'll stop replying after this post, but forward declarations let you do that ;/ it's defined later in the source so it isn't "incomplete"
__________________ http://www.linear.cc/ |
| Fahrenheit is offline | |
| | #10 | |
| Registered User Join Date: Aug 2003
Posts: 470
| Quote:
| |
| okinrus is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem in compiling targa2.c: error: field `ip' has incomplete type.. | Moony | C Programming | 0 | 03-20-2008 07:59 AM |
| How to fix misaligned assignment statements in the source code? | biggyK | C++ Programming | 28 | 07-16-2006 11:35 PM |
| Compiler "Warnings" | Jeremy G | General Discussions | 24 | 04-24-2005 01:09 PM |
| Errors | Rhidian | C Programming | 10 | 04-04-2005 12:22 PM |
| gcc problem | bjdea1 | Linux Programming | 13 | 04-29-2002 06:51 PM |