vendredi 8 mai 2015

field ‘value’ has incomplete type

I have a C++ interdependence problem and i can not understand where the problem is...

Here are my headers:

json.array.h

#ifndef __JSON_ARRAY__
#define __JSON_ARRAY__

#include "json.object.h"

class JSON_OBJECT;

/* JSON_ARRAY */
class JSON_ARRAY {
    int size;
    custom_list<JSON_OBJECT> * container;

...
};

#endif

json.object.h

#ifndef __JSON_OBJECT__
#define __JSON_OBJECT__

#include "hash.h"
#include "elem_info.h"
#include "json.type.h"

class JSON_TYPE;
class elem_info;

/* JSON_OBJECT */
class JSON_OBJECT {
    custom_list<elem_info> *H;
    int HMAX;
    unsigned int (*hash) (std::string);
...
};

#endif

json.type.h

#ifndef __JSON_TYPE__
#define __JSON_TYPE__

#include "json.object.h"
#include "json.array.h"

class JSON_OBJECT;
class JSON_ARRAY;

class JSON_TYPE {
    JSON_ARRAY * _JSON_ARRAY_;
    JSON_OBJECT * _JSON_OBJECT_;
    std::string _JSON_OTHER_;
    std::string _JSON_TYPE_;
...
};

#endif

elem_info.h

#ifndef __ELEM_INFO__
#define __ELEM_INFO__

#include "json.type.h"
class JSON_TYPE;

class elem_info {
public:
    std::string key;
    JSON_TYPE value;
...
}; 

#endif

main.cpp

#include <iostream>
#include <string>

#include "custom_list.h" // it inculdes cpp also
#include "json.type.h"
#include "elem_info.h"
#include "json.object.h"
#include "json.array.h"
#include "json.type.cpp"
#include "elem_info.cpp"
#include "json.object.cpp"
#include "json.array.cpp"


int main()
{
    JSON_ARRAY * root = new JSON_ARRAY;
    JSON_OBJECT obj;
    JSON_OBJECT obj1;
    JSON_OBJECT * obj2 = new JSON_OBJECT;
    JSON_TYPE * type = new JSON_TYPE;
...
}

When i try to compile my code, i have this error:

elem_info.h:10:15: error: field ‘value’ has incomplete type JSON_TYPE value;

It looks like it cant find JSON_TYPE. I cant understand where is the problem. Thanks for your help.

Aucun commentaire:

Enregistrer un commentaire