0

I m quite new to c++ but working hard. I m using the boost::multi_array library in a project but I got problem with typedef.

//in main.h
#include "boost/multi_array.hpp"
#DEFINE D
#include "montecarlo.h"
typedef boost::multi_array<double, D> array_type;
typedef boost::multi_array<int, D> array_type_int;

then I use array_type and array_type int in another header:

//in montecarlo.h
#ifndef MONTECARLO_INCLUDED
#include "main.h"
namespace mc
{
double foo(const array_type_int&,array_type&);
}

#endif

and it's cpp file:

// in montecarlo.cpp
#include"main.h"

void mc::foo(const array_type_int& ARRAYA,array_type& ARRAYB){
    ARRAYA[0]=ARRAYB[0]
}

then I get this errors I cannot understand since my typedef is common to both 2 files

montecarlo.h:5:33: error: ‘array_type_int’ does not name a type
 double distanceEvaluation(const array_type_int&, const array_type&,const int);
                                 ^~~~~~~~~~~~~~
montecarlo.h:5:56: error: ‘array_type’ does not name a type
 double foo(const array_type_int&, const array_type&,const int);

thank you for your help!

Cocco Nat
  • 43
  • 1
  • 4
  • Welcome to Stackoverflow. Please edit you question posting a [mcve]. By constructing your MCVE you will almost certainly find the solution to the problem (in which case you can delete the question) – Mike Kinghan Jan 14 '17 at 11:41
  • The error message says the problem is in montecarlo.h but montecarlo.cpp doesn't include montecarlo.h, or you are not showing all the relevant code. Please post a [mcve]. – n. m. could be an AI Jan 14 '17 at 11:42
  • thanks for paying attention, I cleaned the code. – Cocco Nat Jan 14 '17 at 11:59
  • @CoccoNat Why does `main.h` need to include `montecarlo.h`? The problem you are having seems to be, because of recursive includes. – Algirdas Preidžius Jan 14 '17 at 12:17
  • actually there is a #ifndef MONTECARLO, everything was working when using std::array – Cocco Nat Jan 14 '17 at 13:20

0 Answers0