I am a beginner at c++ and I'm having this problem with nested include files. The code is too big to put here, but this is the part that I'm getting the error:
cvblob.h
#ifdef SWIG
%module cvblob
%{
#include "cvblob.h"
%}
#endif
#ifndef CVBLOB_H
#define CVBLOB_H
#include <iostream>
#include <map>
#include <list>
#include <vector>
#include <limits>
#include <opencv2/opencv.hpp>
#ifndef __CV_BEGIN__
#define __CV_BEGIN__ __BEGIN__
#endif
#ifndef __CV_END__
#define __CV_END__ __END__
#endif
#ifdef __cplusplus
extern "C" {
#endif
...
At line 4 in the above code (#iclude "cvblob.h"
), the error happens:
[package_tracking/cvblob/cvblob.h:26]: (error) #include nested too deeply
The guards are already used, but the error doesn't go away. Sorry that I am not able to put the entire code. If it is not possible to figure it out without the entire code, please answer these questions:
- Should I put the guards (
#ifndef CVBLOB_H
) before the first line? - Is it necessary to put the guards in all the header files?
Thank you! I appreciate any suggestions.