tags:

views:

1702

answers:

4

Hi,

I got error of "field has incomplete type" but nor sure why. Can someone please help? Thanks!

g++ -pipe -W -Wall -fopenmp -ggdb3 -DDEBUG -fno-omit-frame-pointer  -c -o test.o ../../src/test.cc  
In file included from ../../src/test.cc:50:  
../../src/feature_haar.h:14: error: field ‘_count’ has incomplete type  

test.cc

#include "feature_count.h"  
#include "feature_random_counts.h"  
#include "feature_corner.h"  
#include "feature_haar.h" // line 50  

feature_haar.h

#ifndef FEATURE_HAAR_H  
#define FEATURE_HAAR_H  

#include "misc.h"  
#include "feature.h"  
#include "vignette.h"  
#include "feature_count.h"  
#include <cassert>  

class FeatureHaar: public Feature    
{  
 public:  

  FeatureCount _count;// line 14  
...  
}  
#endif  

feature_count.h

#ifndef FEATURE_COUNT_H  
#define FEATURE_COUNT_H  

#include "misc.h"  
#include "feature.h"  
#include "random_rect.h"  
//#include "feature_integral_img.h"  


class FeatureCount: public Feature {  

  public:  

   RandomRect _rect;  


   char _type[buffer_size];  


   // This method returns an upper-caps string to identify the feature  
   const char *name() ;  

   FeatureCount();  


   FeatureCount( int width, int height, const char *type = "black-count", float WHRatio=-1, int roi_x=0, int roi_y=0, int roi_w=0, int roi_h=0 );  


   ~FeatureCount();  




   // compute features from original data i.e. image  
   void compute(double *integral_image, double *feature);  


   // IO  
   void write_humanreadable(ostream *out);  
   void write(ostream *out);  
   void read(istream *in):  
 };  


#endif  

feature.h

 #ifndef FEATURE_H  
 #define FEATURE_H  

 #include "misc.h"  
 #include "vignette.h"  


 class Feature {// generate the feature from the original data of an example, not responsible for holding the feature.  
 public:  
   int _dim;  


   // We need a virtual destructor since there are virtual methods  
   virtual ~Feature();  

   // This method returns an upper-caps string to identify the feature  
   virtual const char *name() = 0;  


   // write the data into files  
  static void write_matrix_data(double ** features, int *labels, int nb_examples, int dim, const char * filename);  
  static void write_index_data(double ** features,int *labels, int nb_examples, int dim, const char * filename);  
  static void write_compact_data(double ** features, int *labels, int nb_examples, int dim, const char * filename);  



   // compute features from original data i.e. image  
   virtual void compute(Vignette *vignette, double * feature); // this function/class not responsible for allocating/deallocation memory for array feature  
   virtual void compute(double *integral_image, double *feature);  



 // feature preprocessing  

   // scaling each feature s.t. its sample max = 1 and min = 0   
   static void scale_features(double *Data, int dim, double *scales_min, double *scales_max);  
   static void compute_linear_scale(double **Data, int size, int dim, double *scales_min, double *scales_max);  

   // standardize each feature s.t. its sample mean = 0 and sample standard deviation = 1  
   static void standardize_features(double *Data, int dim, double *mean, double *std);  
   static void compute_standardization(double **Data, int size, int dim, double *mean, double *std);  


 };  

 #endif  
+1  A: 

Because it apparently has an incomplete type. We'd need to see the definition of FeatureCount to say anything intelligent about why it's an incomplete type.

Jerry Coffin
FeatureCount definition is just added.
Tim
Great. That solved the problem then?
Hans Passant
+2  A: 

Without seeing all the code the likeliest problem is that one of the classes down the inheritance chain of Feature_Haar is simply a forward declaration.

http://msdn.microsoft.com/en-us/library/200xfxh6.aspx

Still can't see anything that might be causing this. Start going through all your include files and look for forward declarations like this:

struct SomeStruct; class Someclass;

Igor Zevaka
+2  A: 

It look like it might be RandomRect.

Richard Pennington
+1  A: 

Thanks for all the people helping me. It's my bad. The definition of FeatureCount is not right. Its member

void read(istream *in): 

should be ended with ";" not ":".

How such a small typo so hard to find?

Tim
That's a really good question: Why can't compilers be more specific about errors that they report. Answer: Because it's really hard, and the compiler has very little notion of context. Sounds like a fun thing to work on.
Richard Pennington
Actually, I'll rephrase the question to be more subjective and argumentative: Which parsing method is best able to produce the best human readable error messages?
Richard Pennington
Richard: the EDG front-end is pretty good, used by comeau, which you can try online: http://comeaucomputing.com/tryitout
Roger Pate
Tim: Even though you answered it and it was pretty much impossible for us to find it (without just asking you for more and more details), seems like you should accept this answer since it is the solution.
Roger Pate